Mae cwcis yn ein helpu i gyflwyno ein gwasanaethau. Drwy ddefnyddio ein gwasanaethau, rydych yn cytuno i'n defnydd cwcis.
Tip: Mae ieithoedd eraill yn Google-Cyfieithu. Gallwch ymweld â'r English fersiwn o'r ddolen hon.
Mewngofnodi
x
or
x
x
cofrestr
x

or

Sut i allforio negeseuon e-bost o sawl ffolderi / is-ddosbarthwr i ragori yn Outlook?

Wrth allforio ffolder gyda'r dewin Mewnforio ac Allforio yn Outlook, nid yw'n cefnogi Cynnwys Is-ddosbarthwyr opsiwn os ydych chi'n allforio y ffolder i ffeil CSV. Fodd bynnag, bydd yn eithaf amser ac yn ddiflas i allforio pob ffolder i ffeil CSV a'i drosi i lyfr gwaith Excel yn llaw. Yma, bydd yr erthygl hon yn cyflwyno VBA i allforio ffolderi lluosog ac is-ddosbarthwyr yn gyflym i lyfrau gwaith Excel yn rhwydd.

Allforio negeseuon e-bost lluosog o sawl ffolderi / is-ddosbarthwr i Excel gyda VBA

Kutools ar gyfer Outlook: 100 + Offer Uwch Newydd ar gyfer Outlook.
Tab Swyddfa: Galluogi Golygu Tablau a Pori yn y Swyddfa, Just Like Chrome, Firefox, IE 8 / 9 / 10.
Bwydlen Clasurol: Dewch â Hen Fwydlenni a Pheiriau Offer Yn ôl i Office 2007, 2010, 2013, 2016 a 2019.

swigod saeth cywir glas Allforio negeseuon e-bost lluosog o sawl ffolderi / is-ddosbarthwr i Excel gyda VBA

Dilynwch y camau isod i allforio negeseuon e-bost o sawl ffolder neu is-ddosbarthwr i lyfrau gwaith Excel gyda VBA yn Outlook.

1. Gwasgwch Alt + F11 allweddi i agor ffenestr Microsoft Visual Basic for Applications.

2. Cliciwch Mewnosod > Modiwlau, ac yna pastiwch y cod VBA i mewn i ffenestr newydd y Modiwl.

VBA: Allforio negeseuon e-bost o sawl ffolderi ac is-ddosbarthwyr i 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. Atebwch y cod VBA uchod fel y bo angen.

(1) Yn lle destination_folder_path yn y cod uchod gyda llwybr ffolder y cyrchfan, byddwch yn achub y llyfrau gwaith allforio, fel C: \ Users \ DT168 \ Documents \ TEST.
(2) Amnewid your_email_accouny \ folder \ subfolder_1 a your_email_accouny \ folder \ subfolder_2 mewn cod uchod gyda llwybrau ffolder o is-ffolderi yn Outlook, megis Kelly@extendoffice.com \ Inbox \ A ac Kelly@extendoffice.com \ Inbox \ B

4. Gwasgwch y F5 allwedd neu glicio ar Run botwm i redeg y VBA hwn. Ac yna cliciwch ar y OK botwm yn y blwch deialog Allforio Outlook Ffolderi i Excel. Gweler y sgrin:

Ac erbyn hyn mae negeseuon e-bost o bob is-ddileu neu ffolderi penodedig yn y cod VBA uchod yn cael eu hallforio a'u harbed i mewn i lyfrau gwaith Excel.


swigod saeth cywir glasErthyglau Perthnasol



Kutools ar gyfer Outlook

Mwy na Swyddogaethau Uwch 100 ar gyfer Outlook 2010, 2013, 2016, 2019 a 365

sgrinio kutools ar gyfer rhagolygon bach ar gyfer baner 201812

Mwy o Nodweddion | Lawrlwythiad Am Ddim | $ 39.00 yn unig ar gyfer cannoedd o swyddogaethau

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Montaser Abu Roumi · 8 months ago
    hello dear, every thing working well many thanks but the body is not exported, how can i export email body too, the excel file has just (Subject, Received, and Sender), if you can update me with it will solve a huge matter in my business many thanks again
    • To post as a guest, your comment is unpublished.
      kellytte · 1 months ago
      Hi Montaser,
      The VBA script runs based on Outlook’s Export feature which doesn’t support exporting message content when bulk exporting emails from a mail folder. Therefore, this VBA script cannot export message content too.
  • To post as a guest, your comment is unpublished.
    ClickMonster · 1 years ago
    How do I get this to automatically recurse into subfolders?