如何使用带有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
答案 0 :(得分:4)
MAPI控件使用简单MAPI,它不处理HTML。直接使用简单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
答案 1 :(得分:1)
请 .MsgNoteText =“”; .AttachmentPathName = result
即。
With MAPIMessages1
.Compose
.RecipAddress = sSendTo
.AddressResolveUI = True
.ResolveName
.MsgSubject = sSubject
.MsgNoteText =""
.AttachmentPathName = "c:\yourHtml.html"
.Send False
End With