是的,我正在尝试通过 lotus notes 发送电子邮件表单一个 excel 电子表格,它有一个附件,并且正文需要是 HTML。
我有一些我读过的代码应该允许我这样做,但事实并非如此。如果没有 HTML 正文,附件将发送,当我暗示电子邮件仍然发送 HTML 正文但附件消失时,我尝试重新排列代码的顺序,删除可能不需要但一切都是徒劳的位。
(您需要参考 Lotus Domino Objects 来运行此代码。strEmail 是电子邮件地址 strAttach 是附件的字符串位置 strSubject 是主题文本 strBody 是正文)
Sub Send_Lotus_Email(strEmail, strAttach, strSubject, strBody)
Dim noSession As Object, noDatabase As Object, noDocument As Object
Dim obAttachment As Object, EmbedObject As Object
Const EMBED_ATTACHMENT As Long = 1454
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", "")
'If Lotus Notes is not open then open the mail-part of it.
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
'Create the e-mail and the attachment.
Set noDocument = noDatabase.CreateDocument
Set obAttachment = noDocument.CreateRichTextItem("strAttach")
Set EmbedObject = obAttachment.EmbedObject(EMBED_ATTACHMENT, "", strAttach)
'Add values to the created e-mail main properties.
With noDocument
.Form = "Memo"
.SendTo = strEmail
'.Body = strBody ' Where to send the body if HTML body isn't used.
.Subject = strSubject
.SaveMessageOnSend = True
End With
noSession.ConvertMIME = False
Set Body = noDocument.CreateMIMEEntity("Body") ' MIMEEntity to support HTML
Set stream = noSession.CreateStream
Call stream.WriteText(strBody) ' Write the body text to the stream
Call Body.SetContentFromText(stream, "text/html;charset=iso-8859-1", ENC_IDENTITY_8BIT)
noSession.ConvertMIME = True
'Send the e-mail.
With noDocument
.PostedDate = Now()
.Send 0, strEmail
End With
'Release objects from the memory.
Set EmbedObject = Nothing
Set obAttachment = Nothing
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
结束子
如果有人能指出我正确的方向,我将不胜感激。
编辑:我做了更多调查,发现了一个奇怪的地方,如果我查看已发送的文件夹,即使您进入电子邮件,即使在已发送的 HTML 中,电子邮件也都有带有附件的回形针图标那些不显示附件。