有時,您可能希望批量捕獲特定會話中的所有電子郵件,然後將其作為文本文件批量導出到本地文件夾。 本文將教您如何快速獲得它。
由於某些原因,您可能需要將特定會話中的所有電子郵件導出到本地驅動器。 如果您手動執行此操作,即找到並保存一個,這將是一個繁瑣而艱鉅的任務。 因此,您最好尋求其他更快的方法,例如以下一種。 它將使用一段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
