首页 文章

Outlook电子邮件中没有正文

提问于
浏览
0

我试图在收到Outlook的电子邮件时获取电子邮件的正文和头部 . 我正在使用 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

正在成功调用此函数,我可以使用以下命令获取电子邮件的 Headers :

MsgBox Msg

但是当我尝试使用 Msg.Body 时, MsgBox 中没有显示任何内容 . 另外,当我使用 Msg.HTMLBody 时,我可以在 MsgBox 中看到html,但标签中仍然没有任何内容 .

我在这里做错了什么建议?

1 回答

  • 2

    我最终自己搞清楚了 .

    因为我正在使用的电子邮件是IMAP,所以只有主题行从服务器下载,直到单击电子邮件,然后下载正文 .

    通过首先访问主题行,我能够访问电子邮件的正文,如下所示:

    Set Msg = oNS.GetItemFromID(EntryIDCollection)
    MsgBox Msg
    MsgBox Msg.Body
    

相关问题