我正在尝试通过Lotus笔记发送电子邮件表格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
结束子
如果somone可以指出我正确的方向,我将不胜感激 .
编辑:我已经做了一些调查,我发现一个奇怪的是,如果我看一下发送的文件夹,电子邮件都有附件的回形针图标,即使你进入电子邮件甚至在发送的HTML中那些没有显示附件 .