2

如何使用带有 HTML 正文的 MAPI 发送邮件?我需要在消息正文中创建表。我正在使用 vb6 和 MAPI 控件。有任何想法吗?

Function MailSend(sSendTo As String, sSubject As String, sText As String) As Boolean
    On Error GoTo ErrHandler

    With MAPISession1
        If .SessionID = 0 Then
            .DownLoadMail = False
            .LogonUI = True
            .SignOn
            .NewSession = True
            MAPIMessages1.SessionID = .SessionID
        End If
    End With
    With MAPIMessages1
        .Compose
        .RecipAddress = sSendTo
        .AddressResolveUI = True
        .ResolveName
        .MsgSubject = sSubject
        .MsgNoteText = sText
        .Send False
    End With
    MailSend = True
    Exit Function
ErrHandler:
    'MsgBox Err.Description
    MailSend = False
End Function
4

2 回答 2

5

MAPI 控件使用不处理 HTML 的简单 MAPI。直接使用 Simple MAPI (MAPISendMail) 时有一个技巧 - 将正文设置为 NULL 并附加 HTML 文件:它将用作邮件正文。我不知道这个技巧是否适用于 MAPI 控件。

为什么不切换到使用 Outlook 对象模型?它完全能够处理 HTML:

set App = CreateObject("Outlook.Application")
set NS = App.GetNmaespace("MAPI")
NS.Logon
set Msg = App.CreateItem(0)
Msg.To = sSendTo
Msg.Subject = sSubject
Msg.HTMLBody = sYourHTMLBody
Msg.Send 'or Msg.Display
于 2013-04-05T12:46:11.163 回答
1

保持 .MsgNoteText =""; .AttachmentPathName = 结果

IE。

With MAPIMessages1
    .Compose
    .RecipAddress = sSendTo
    .AddressResolveUI = True
    .ResolveName
    .MsgSubject = sSubject
    .MsgNoteText =""
    .AttachmentPathName = "c:\yourHtml.html"
    .Send False
End With
于 2016-05-18T12:14:43.753 回答