使用 access vba 将图像嵌入到邮件正文中

问题描述 投票:0回答:3

我目前正在使用下面的代码从 Access 发送带有附件的电子邮件。但我到处搜索,但没有找到将附件嵌入到电子邮件正文本身的解决方案。有人可以帮我吗?

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
ms-access vba lotus-notes
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 怎么做。


0
投票

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

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


0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.