Conas ríomhphoist a easpórtáil ó iliomad fillteán / fofhillteán le barr feabhais a chur ar Outlook?
Nuair a dhéantar fillteán a onnmhairiú leis an draoi Iompórtála agus Easpórtála in Outlook, ní thacaíonn sé leis an Cuir Fofhillteáin san áireamh rogha má onnmhairíonn tú an fillteán go comhad CSV. Tógfaidh sé go leor ama agus tedious, áfach, gach fillteán a easpórtáil go comhad CSV agus ansin é a thiontú go leabhar oibre Excel de láimh. Anseo, tabharfaidh an t-alt seo VBA isteach chun ilfhillteáin agus fofhillteáin a onnmhairiú go tapa chuig leabhair oibre Excel ar a suaimhneas.
Easpórtálacha ríomhphoist iomadúla ó iliomad fillteán / fofhillteán go Excel le VBA
- Uathoibriú ríomhphost le Auto CC / BCC, Auto Ar Aghaidh le rialacha; seol Freagra Auto (As Oifig) gan freastalaí malartaithe a bheith ag teastáil...
- Faigh meabhrúcháin cosúil le Rabhadh BCC nuair a thugann tú freagra ar gach duine agus tú ar an liosta BCC, agus Meabhraigh Nuair a bhíonn Ceangaltáin ar Iarraidh le haghaidh ceangaltán dearmadta...
- Feabhas a chur ar éifeachtacht ríomhphoist le Freagra (Gach) Le Ceangaltáin, Auto Cuir Beannacht nó Dáta & Am isteach i Síniú nó Ábhar, Freagair Ríomhphoist Il...
- Sruthlínigh ríomhphost le Ríomhphoist a Athghairm, Uirlisí Ceangail (Comhbhrúigh Uile, Sábháil Uile...), Bain Dúblaigh, agus Tuarascáil Thapa...
Easpórtálacha ríomhphoist iomadúla ó iliomad fillteán / fofhillteán go Excel le VBA
Lean na céimeanna thíos le do thoil chun ríomhphoist a easpórtáil ó iliomad fillteán nó fofhillteán chuig leabhair oibre Excel le VBA in Outlook.
1. Brúigh Eile + F11 eochracha chun an fhuinneog Microsoft Visual Basic for Applications a oscailt.
2. cliceáil Ionsáigh > Modúil, agus ansin greamaigh faoi bhun chód VBA isteach i bhfuinneog nua an Mhodúil.
VBA: Easpórtáil ríomhphoist ó iliomad fillteán agus fofhillteán chuig Excel
Const MACRO_NAME = "Export Outlook Folders to Excel"
Sub ExportMain()
ExportToExcel "destination_folder_path\A.xlsx", "your_email_accouny\folder\subfolder_1"
ExportToExcel "destination_folder_path\B.xlsx", "your_email_accouny\folder\subfolder_2"
MsgBox "Process complete.", vbInformation + vbOKOnly, MACRO_NAME
End Sub
Sub ExportToExcel(strFilename As String, strFolderPath As String)
Dim olkMsg As Object
Dim olkFld As Object
Dim excApp As Object
Dim excWkb As Object
Dim excWks As Object
Dim intRow As Integer
Dim intVersion As Integer
If strFilename <> "" Then
If strFolderPath <> "" Then
Set olkFld = OpenOutlookFolder(strFolderPath)
If TypeName(olkFld) <> "Nothing" Then
intVersion = GetOutlookVersion()
Set excApp = CreateObject("Excel.Application")
Set excWkb = excApp.Workbooks.Add()
Set excWks = excWkb.ActiveSheet
'Write Excel Column Headers
With excWks
.Cells(1, 1) = "Subject"
.Cells(1, 2) = "Received"
.Cells(1, 3) = "Sender"
End With
intRow = 2
For Each olkMsg In olkFld.Items
'Only export messages, not receipts or appointment requests, etc.
If olkMsg.Class = olMail Then
'Add a row for each field in the message you want to export
excWks.Cells(intRow, 1) = olkMsg.Subject
excWks.Cells(intRow, 2) = olkMsg.ReceivedTime
excWks.Cells(intRow, 3) = GetSMTPAddress(olkMsg, intVersion)
intRow = intRow + 1
End If
Next
Set olkMsg = Nothing
excWkb.SaveAs strFilename
excWkb.Close
Else
MsgBox "The folder '" & strFolderPath & "' does not exist in Outlook.", vbCritical + vbOKOnly, MACRO_NAME
End If
Else
MsgBox "The folder path was empty.", vbCritical + vbOKOnly, MACRO_NAME
End If
Else
MsgBox "The filename was empty.", vbCritical + vbOKOnly, MACRO_NAME
End If
Set olkMsg = Nothing
Set olkFld = Nothing
Set excWks = Nothing
Set excWkb = Nothing
Set excApp = Nothing
End Sub
Public Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder
Dim arrFolders As Variant
Dim varFolder As Variant
Dim bolBeyondRoot As Boolean
On Error Resume Next
If strFolderPath = "" Then
Set OpenOutlookFolder = Nothing
Else
Do While Left(strFolderPath, 1) = "\"
strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
Loop
arrFolders = Split(strFolderPath, "\")
For Each varFolder In arrFolders
Select Case bolBeyondRoot
Case False
Set OpenOutlookFolder = Outlook.Session.Folders(varFolder)
bolBeyondRoot = True
Case True
Set OpenOutlookFolder = OpenOutlookFolder.Folders(varFolder)
End Select
If Err.Number <> 0 Then
Set OpenOutlookFolder = Nothing
Exit For
End If
Next
End If
On Error GoTo 0
End Function
Function GetSMTPAddress(Item As Outlook.MailItem, intOutlookVersion As Integer) As String
Dim olkSnd As Outlook.AddressEntry
Dim olkEnt As Object
On Error Resume Next
Select Case intOutlookVersion
Case Is < 14
If Item.SenderEmailType = "EX" Then
GetSMTPAddress = SMTPEX(Item)
Else
GetSMTPAddress = Item.SenderEmailAddress
End If
Case Else
Set olkSnd = Item.Sender
If olkSnd.AddressEntryUserType = olExchangeUserAddressEntry Then
Set olkEnt = olkSnd.GetExchangeUser
GetSMTPAddress = olkEnt.PrimarySmtpAddress
Else
GetSMTPAddress = Item.SenderEmailAddress
End If
End Select
On Error GoTo 0
Set olkPrp = Nothing
Set olkSnd = Nothing
Set olkEnt = Nothing
End Function
Function GetOutlookVersion() As Integer
Dim arrVer As Variant
arrVer = Split(Outlook.Version, ".")
GetOutlookVersion = arrVer(0)
End Function
Function SMTPEX(olkMsg As Outlook.MailItem) As String
Dim olkPA As Outlook.propertyAccessor
On Error Resume Next
Set olkPA = olkMsg.propertyAccessor
SMTPEX = olkPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x5D01001E")
On Error GoTo 0
Set olkPA = Nothing
End Function
3. Déan an cód VBA thuas a choigeartú de réir mar is gá duit.
(1) Ionadaigh ceann scríbe_folder_path sa chód thuas le cosán fillteán an fhillteáin chinn scríbe sábhálfaidh tú na leabhair oibre a onnmhairítear, mar shampla C: \ Úsáideoirí \ DT168 \ Doiciméid \ TÁSTÁIL.
(2) Cuir cosáin fillteáin na bhfofhillteán in Outlook, mar shampla, in ionad do_email_accouny \ folder \ subfolder_1 agus your_email_accouny \ folder \ subfolder_2 sa chód thuas \Bosca Isteach\A agus \Bosca Isteach\B
4. Brúigh an F5 eochair nó cliceáil ar an Rith cnaipe chun an VBA seo a rith. Agus ansin cliceáil ar an OK cnaipe sa bhosca popping amach Export Outlook Folders go bosca dialóige Excel. Féach an pictiúr:
Agus anois déantar ríomhphoist ó gach fofhillteán nó fillteán sonraithe sa chód VBA thuas a onnmhairiú agus a shábháil i leabhair oibre Excel.
Airteagail gaolmhara
R-phoist a easpórtáil de réir raon dáta go comhad Excel nó comhad PST in Outlook
Liosta easpórtála agus priontála de na fillteáin agus na fofhillteáin uile in Outlook
Uirlisí Táirgiúlachta Oifige is Fearr
Kutools le haghaidh Outlook - Níos mó ná 100 Gnéithe cumhachtacha chun do Outlook a shárú
🤖 Cúntóir Ríomhphoist AI: Ríomhphoist pro toirt le draíocht AI - aon-cliceáil chun freagraí genius, ton foirfe, máistreacht ilteangach. Trasfhoirmigh ríomhphost gan stró! ...
📧 Uathoibriú Ríomhphoist: As Oifig (Ar fáil do POP agus IMAP) / Sceideal Seol Ríomhphoist / Auto CC/BCC de réir Rialacha Agus Ríomhphost á Sheoladh / Auto Ar Aghaidh (Ardrialacha) / Beannacht Auto Cuir leis / Scoilt Ríomhphoist Ilfhaighteoirí go huathoibríoch i dTeachtaireachtaí Aonair ...
📨 Bainistíocht Ríomhphost: Ríomhphoist a Athghairm go héasca / Bloc Ríomhphoist Scam ag Ábhair agus Daoine Eile / Scrios Ríomhphoist Dúblacha / Cuardach Casta / Comhdhlúthaigh Fillteáin ...
📁 Ceangaltáin Pro: Sábháil Baisc / Baisc Dícheangail / Comhbhrú Baisc / Auto Sábháil / Auto Dícheangail / Comhbhrúite Auto ...
🌟 Draíocht Chomhéadain: 😊Níos mó Emojis Pretty and Cool / Treisiú Do Tháirgiúlacht Outlook le Radhairc Tabbed / Íoslaghdaigh Outlook In ionad Deiridh ...
???? Wonders aon-cliceáil: Freagair Gach Duine le Ceangaltáin Isteach / Ríomhphoist Frith-Iascaireachta / 🕘 Taispeáin Crios Ama an tSeoltóra ...
👩🏼🤝👩🏻 Teagmhálaithe & Féilire: Baisc Cuir Teagmhálacha Ó Ríomhphoist Roghnaithe / Roinn Grúpa Teagmhála ar Ghrúpaí Aonair / Bain Meabhrúcháin Breithlá ...
Thar Gnéithe 100 Fan le do Thaiscéalaíocht! Cliceáil Anseo le Tuilleadh Amach.