跳到主要內容

如何在Outlook中將多個選定的電子郵件批量保存為MSG文件?

在Outlook中將電子郵件另存為MSG文件很容易。 如何在Outlook中批量保存多個選定的電子郵件作為單個MSG文件? 本文將向您展示一種實現它的方法。

使用VBA代碼將多個選定的電子郵件另存為MSG文件


使用VBA代碼將多個選定的電子郵件另存為MSG文件

以下VBA代碼可以幫助您在Outlook中批量存儲多個選定的電子郵件作為單個MSG文件。 請執行以下操作。

1.選擇要另存為MSG文件的電子郵件。 然後,同時按Alt + F11鍵以打開“ Microsoft Visual Basic應用程序”窗口。

2.在“ Microsoft Visual Basic應用程序”窗口中,單擊“插入”>“模塊”,然後將以下VBA代碼複製到“模塊”窗口中。

VBA代碼:將多個選定的電子郵件另存為Outlook中的單個MSG文件

Public Sub SaveMessageAsMsg()
'Update by Extendoffice 2018/3/5
Dim xMail As Outlook.MailItem
Dim xObjItem As Object
Dim xPath As String
Dim xDtDate As Date
Dim xName, xFileName As String
On Error Resume Next
Set xShell = CreateObject("Shell.Application")
Set xFolder = xShell.BrowseForFolder(0, "Select a folder:", 0, strStartingFolder)
If Not TypeName(xFolder) = "Nothing" Then
    Set xFolderItem = xFolder.self
    xFileName = xFolderItem.Path & "\"
Else
    xFileName = ""
    Exit Sub
End If
For Each xObjItem In Outlook.ActiveExplorer.Selection
    If xObjItem.Class = olMail Then
        Set xMail = xObjItem
        xName = xMail.Subject
        xDtDate = xMail.ReceivedTime
        xName = Format(xDtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
          vbUseSystem) & Format(xDtDate, "-hhnnss", _
          vbUseSystemDayOfWeek, vbUseSystem) & "-" & xName & ".msg"
        xPath = xFileName + xName
        xMail.SaveAs xPath, olMSG
    End If
Next
End Sub

3.按F5鍵運行代碼。

4. 在瀏覽資料夾對話方塊中,請指定儲存 MSG 檔案的資料夾,然後按一下確定按鈕。 看截圖:

現在,所有選定的電子郵件都儲存為單獨的 MSG 文件,如下圖所示。


在Outlook中輕鬆將選定的電子郵件另存為不同格式的文件:

隨著 批量保存 的效用 Kutools for Outlook,您可以輕鬆地將多個選定的電子郵件另存為Outlook中的單個HTML格式文件,TXT格式文件,Word文檔,CSV文件以及PDF文件,如下圖所示。 立即下載並試用! (60 天免費試用)


最佳辦公生產力工具

Kutools for Outlook - 超過 100 種強大的功能可增強您的 Outlook

📧 電子郵件自動化: 外出(適用於 POP 和 IMAP)  /  安排發送電子郵件  /  發送電子郵件時按規則自動抄送/密件副本  /  自動轉送(進階規則)   /  自動添加問候語   /  自動將多收件者電子郵件拆分為單獨的訊息 ...

📨 電子郵件管理: 輕鬆回憶電子郵件  /  按主題和其他人阻止詐騙電子郵件  /  刪除重複的電子郵件  /  進階搜索  /  合併資料夾 ...

📁 附件專業版批量保存  /  批量分離  /  批量壓縮  /  自動保存   /  自動分離  /  自動壓縮 ...

🌟 介面魔法: 😊更多又漂亮又酷的表情符號   /  使用選項卡式視圖提高 Outlook 工作效率  /  最小化 Outlook 而不是關閉 ...

👍 一鍵奇蹟: 使用傳入附件回覆全部  /   反網路釣魚電子郵件  /  🕘顯示寄件者的時區 ...

👩🏼‍🤝‍👩🏻 通訊錄和行事曆: 從選定的電子郵件中大量新增聯絡人  /  將聯絡人群組拆分為各組  /  刪除生日提醒 ...

超過 100特點 等待您的探索! 按此處了解更多。

閱讀更多       免費下載      購買
 

 

Comments (5)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
It doesn't seem to work when emails are displayed in conversation mode or from a Group folder.
This comment was minimized by the moderator on the site
Hi, i am new to macro. i am looking for a macro that allows me to save the filename, not by subject or time. But by the reference # found inside the email body. This macro works well when i save multiple emails into my folder. But as i want each email to be saved using the reference #, would you have a macro for it? The reference # is found on the 6th row of the emails body (REF : WL344ET2), that i received everyday. Appreciate if anyone can help on this and thank you in advance.
This comment was minimized by the moderator on the site
When there is a ":" in the subject, this code cannot copy the whole subject to be the name of the saved message, is there any way to solve this problem?
This comment was minimized by the moderator on the site
change line 21 to xName="". The saved message filname will not include the subject anymore.
This comment was minimized by the moderator on the site
A better way is to always replace ":" with blanks adding this line under xName = xMail.Subject

xName = Replace(xName, ":", "")
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations