有时,您可能希望批量捕获特定对话中的所有电子邮件,然后将它们作为文本文件批量导出到本地文件夹。 本文将教您如何快速获得它。
出于某种原因,您可能需要将特定对话中的所有电子邮件导出到本地驱动器。 如果手动进行,即一个一个地查找和保存,将是一项繁琐而艰巨的工作。 因此,您最好寻求其他更快捷的方法,例如下面的方法。 它将使用一段 VBA 代码毫不费力地得到它。
将对话中的所有邮件批量导出为文本文件
- 首先,启动您的 Outlook 应用程序。
- 然后按“Alt + F11”键按钮访问 Outlook VBA 编辑器。
- 随后,在新窗口中,您需要打开一个未使用的模块或直接插入一个新模块。
- 接下来,您应该将以下 VBA 代码复制并粘贴到该模块中。
Public strFilePath, strFileName As String
Sub ExportMailsInConversationAsTXT()
Dim objSelectedMail As Outlook.MailItem
Dim objConversation As Outlook.Conversation
Dim objMail As Outlook.MailItem
Set objSelectedMail = ActiveExplorer.Selection.Item(1)
Set objConversation = objSelectedMail.GetConversation
If Not (objConversation Is Nothing) Then
'Get all root items in this conversation
For Each objMail In objConversation.GetRootItems
strFileName = objMail.Subject
'Remove the unsupported characters in email subject
strFileName = Replace(strFileName, "/", " ")
strFileName = Replace(strFileName, "\", " ")
strFileName = Replace(strFileName, ":", "")
strFileName = Replace(strFileName, "?", " ")
strFileName = Replace(strFileName, Chr(34), " ")
strFileName = Format(objMail.ReceivedTime, "YYYY-MM-DD") & "_" & strFileName & ".txt"
'Export as Text files
'Change "E:\" to other local folder path as per your needs
strFilePath = "E:\" & strFileName
objMail.SaveAs strFilePath, OLTXT
'Process all children as well
Call ProcessChildren(objMail, objConversation)
Next
End If
MsgBox "Complete!", vbExclamation
End Sub
Sub ProcessChildren(objCurMail As Outlook.MailItem, objCurConversation As Outlook.Conversation)
Dim objItems As Outlook.SimpleItems
Dim objItem As Outlook.MailItem
Set objItems = objCurConversation.GetChildren(objCurMail)
If objItems.Count > 0 Then
For Each objItem In objItems
strFileName = objItem.Subject
strFileName = Replace(strFileName, "/", " ")
strFileName = Replace(strFileName, "\", " ")
strFileName = Replace(strFileName, ":", "")
strFileName = Replace(strFileName, "?", " ")
strFileName = Replace(strFileName, Chr(34), " ")
strFileName = Format(objItem.ReceivedTime, "yyyy-mm-dd") & "_" & strFileName & ".txt"
strFilePath = "E:\" & strFileName
objItem.SaveAs strFilePath, OLTXT
'Process all children recursively
Call ProcessChildren(objItem, objCurConversation)
Next
End If
End Sub
- 之后,您可以像往常一样将新的 VBA 项目添加到快速访问工具栏。
- 稍后确保您的 Outlook 宏安全级别为低。
- 最后,你可以试试看。
- 首先,选择一个电子邮件。
- 然后单击快速访问工具栏中的新宏按钮。
- 当您收到“完成”消息时,您可以打开预定义的本地文件夹,您将在其中看到“TXT”格式的电子邮件。
损坏后恢复 PST 数据的技巧
通常,在 Outlook 中,您可能会遇到各种 Outlook 错误,其中一些错误可能非常严重,以至于直接导致 PST 损坏。 这时候,你需要采取行动 修复PST 文件以找回您的宝贵数据。 在这种情况下,您可以重新使用信誉良好且经过充分验证的工具,例如 DataNumen Outlook Repair.
作者简介:
Shirley Zhang 是一位数据恢复专家 DataNumen, Inc.,它是数据恢复技术领域的世界领先者,包括 恢复 sql server 和 outlook 修复软件产品。 欲了解更多信息,请访问 datanumen.com
