0

我目前正在使用下面的代码从访问权限中发送带有附件的邮件。但是我到处搜索,但没有找到将附件嵌入邮件正文的方法。任何人都可以帮助我。

Option Compare Database

Option Explicit

'Declare public object variables
Public mkfDoc As String
Public Subject, Attachment, Recipient, copyto, BodyText, UserName, SaveIt

Public Maildb As Object        'The mail database
Public MailDbName As String    'The current users notes mail database name
Public MailDoc As Object       'The mail document itself
Public AttachME As Object      'The attachment richtextfile object
Public Session As Object       'The notes session
Public EmbedObj As Object      'The embedded object (Attachment)


Public Function sendNotes(ByVal strTo As String, ByVal Attachment As String, ByVal strSubject As String, ByVal strBody As String)

'Set up the objects required for Automation into lotus notes
    Subject = strSubject
    'Attachment = "c:\foldername\filename.extension"
    Recipient = Split(strTo, ",")
'Set bodytext for mail offer - language depends on field in offprofrm
    BodyText = strBody
'Start a session to notes
        Set Session = CreateObject("Notes.NotesSession")
'Open the mail database in notes
        Set Maildb = Session.GETDATABASE("", MailDbName)
        If Maildb.ISOPEN = True Then
            'Already open for mail
        Else
            Maildb.OPENMAIL
        End If
'Set up the new mail document
        Set MailDoc = Maildb.CREATEDOCUMENT
        MailDoc.Form = "Memo"
        MailDoc.sendto = Recipient
        MailDoc.Subject = Subject
        MailDoc.Body = BodyText
        MailDoc.SAVEMESSAGEONSEND = True


'Set up the embedded object and attachment and attach it
        If Attachment <> "" Then
            Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
            Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
            MailDoc.CREATERICHTEXTITEM ("Attachment")
        End If
'Send the document + notify
        MailDoc.PostedDate = NOW() 'Gets the mail to appear in the sent items folder
        MailDoc.SEND 0, Recipient
'Clean Up
        Set Maildb = Nothing
        Set MailDoc = Nothing
        Set AttachME = Nothing
        Set Session = Nothing
        Set EmbedObj = Nothing
End Function
4

3 回答 3

1

在正文字段中创建包含附件的电子邮件的一个好方法是使用 MIME 格式。

Set body = MailDoc.CreateMIMEEntity("Body") 
...

看看http://www-10.lotus.com/ldd/bpmpblog.nsf/dx/creating-a-mime-email-with-attachmenthttps://stackoverflow.com/a/2514633/2065611如何去做吧。

于 2013-05-20T20:42:20.457 回答
0

据我所知,您只能使用 NotesUIDocument 类的 Import 方法将图像嵌入富文本字段中,除非您想要更复杂的方法。

我认为这是可能的两种方法: * 使用 GeniiSoft(商业产品)的 Midas LSX * 将文档导出为 DXL,添加图像(编码为 Base64),然后将 DXL 作为 Notes 文档导入回来。

于 2013-05-20T01:04:33.270 回答
0

首先,您需要创建一个 Outlook 邮件对象,然后使用适当的 <img src='myfile.jpg'> 标签编写邮件正文(在 html 中)。请注意以下几点:
- 嵌入的图像必须保存在您的计算机上(作为 jpg 文件或 png 文件);
- 自 Outlook 2013 起,嵌入图像也必须附加到电子邮件中。

在下面的链接中,您将找到所有详细信息和工作代码模板 http://vba-useful.blogspot.fr/2014/01/send-html-email-with-embedded-images.html

于 2014-02-02T17:50:25.760 回答