[英]Sending messages with HTML contents using the MAPI control in VB6
如何使用带有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
MAPI控件使用不处理HTML的简单MAPI。 直接使用简单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
保持.MsgNoteText =“”; .AttachmentPathName =结果
即。
With MAPIMessages1
.Compose
.RecipAddress = sSendTo
.AddressResolveUI = True
.ResolveName
.MsgSubject = sSubject
.MsgNoteText =""
.AttachmentPathName = "c:\yourHtml.html"
.Send False
End With
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.