跳至主要内容

如何在Outlook中批量将多封选中的邮件保存为MSG文件?

Author: Siluvia Last Modified: 2025-05-07

在Outlook中将单封邮件保存为MSG文件非常简单。那么,如何在Outlook中批量将多封选中的邮件保存为单独的MSG文件呢?本文将向您展示一种实现方法。

使用VBA代码将多封选中的邮件保存为MSG文件


使用VBA代码将多封选中的邮件保存为MSG文件

以下VBA代码可以帮助您在Outlook中批量将多封选中的邮件保存为单独的MSG文件。请按照以下步骤操作:

1. 选择要保存为MSG文件的邮件。然后同时按“Alt” + “F11”键打开Microsoft Visual Basic for Applications窗口。

2. 在Microsoft Visual Basic for Applications窗口中,点击“插入” > “模块”,然后将下面的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文件,然后点击“确定”按钮。见截图:

the screenshot of step 1 about saving selected emails as msg files using vba in outlook

现在所有选中的邮件都已保存为单独的MSG文件,如下截图所示。

the screenshot of step 2 about saving selected emails as msg files using vba in outlook

轻松在Outlook中将选中的邮件保存为不同格式的文件:

借助“Kutools for Outlook”的“批量保存”工具,您可以轻松将多封选中的邮件保存为单独的HTML格式文件、TXT格式文件、Word文档、CSV文件以及PDF文件,如下截图所示。立即下载Kutools for Outlook的免费版本!

ad about saving emails as multiple file formats in outlook with kutools for outlook