将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)
Next
MsgBox “Email text extraction completed!”, vbOKOnly + vbInformation, “DONE!”
ts.Close
Set objItem = Nothing
End Sub
此外比较有用的属性还有下面几个:
ReceivedTime 接收时间
SenderName 发件人姓名
Subject 主题
To 收件人(特别注意,有些Outlook邮件没有收件人,也就是没有这个项!)