Outlook VBA 将文件多个邮件的内容保存在一个 TXT 文件中

将Outlook中多个邮件的内容保存在一个 TXT 文件中。运行后需要手工输入一个文件名。

Sub SaveBodytoText()
Dim objItem As Object
Dim strFile As String

‘Exit if you don’t choose any files
If ActiveExplorer.Selection.Count = 0 Then Exit Sub

strFile = InputBox(“Please enter the full path and file name for the merged text:”, “Enter File Name”)

‘write content to a file
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set ts = fso.CreateTextFile(strFile, ForAppending, True)

‘write all the chosen file to a file
For Each objItem In ActiveExplorer.Selection
ts.Write (objItem.Body)

MsgBox “Email text extraction completed!”, vbOKOnly + vbInformation, “DONE!”

Set objItem = Nothing

End Sub


ReceivedTime 接收时间
SenderName 发件人姓名
Subject 主题
To 收件人(特别注意,有些Outlook邮件没有收件人,也就是没有这个项!)


电子邮件地址不会被公开。 必填项已用*标注