Outlook 电子邮件中没有 body
No body in outlook email
我试图在 outlook 中收到电子邮件后获取 body 和标题。我正在使用 NewMailEx
事件处理程序来管理所有收到的电子邮件。
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim olApp As Outlook.Application
Dim oNS As NameSpace
Dim oFolder As MAPIFolder
Dim oNewMail As MailItem
Set olApp = Outlook.Application
Set oNS = GetNamespace("MAPI")
Set oFolder = oNS.GetDefaultFolder(olFolderInbox)
Set oNewMail = oFolder.Items.GetFirst
Set Msg = oNS.GetItemFromID(EntryIDCollection)
MsgBox Msg.Body
End Sub
此函数调用成功,我可以通过以下方式获取电子邮件的header:
MsgBox Msg
但是当我尝试使用 Msg.Body
时,MsgBox
中没有显示任何内容。此外,当我使用 Msg.HTMLBody
时,我可以在 MsgBox
中看到 html,但标签中仍然没有任何内容。
对我在这里做错了什么有什么建议吗?
最后我自己解决了这个问题。
因为我正在处理的电子邮件是 IMAP,只有主题行从服务器下载,直到单击电子邮件,然后下载正文。
我能够通过事先访问主题行来访问电子邮件正文,如下所示:
Set Msg = oNS.GetItemFromID(EntryIDCollection)
MsgBox Msg
MsgBox Msg.Body
我试图在 outlook 中收到电子邮件后获取 body 和标题。我正在使用 NewMailEx
事件处理程序来管理所有收到的电子邮件。
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim olApp As Outlook.Application
Dim oNS As NameSpace
Dim oFolder As MAPIFolder
Dim oNewMail As MailItem
Set olApp = Outlook.Application
Set oNS = GetNamespace("MAPI")
Set oFolder = oNS.GetDefaultFolder(olFolderInbox)
Set oNewMail = oFolder.Items.GetFirst
Set Msg = oNS.GetItemFromID(EntryIDCollection)
MsgBox Msg.Body
End Sub
此函数调用成功,我可以通过以下方式获取电子邮件的header:
MsgBox Msg
但是当我尝试使用 Msg.Body
时,MsgBox
中没有显示任何内容。此外,当我使用 Msg.HTMLBody
时,我可以在 MsgBox
中看到 html,但标签中仍然没有任何内容。
对我在这里做错了什么有什么建议吗?
最后我自己解决了这个问题。
因为我正在处理的电子邮件是 IMAP,只有主题行从服务器下载,直到单击电子邮件,然后下载正文。
我能够通过事先访问主题行来访问电子邮件正文,如下所示:
Set Msg = oNS.GetItemFromID(EntryIDCollection)
MsgBox Msg
MsgBox Msg.Body