使用 Access VBA 将 OLE 对象图像插入 html 电子邮件

Inserting an OLE Object image into an html email using Access VBA

我必须将存储在 OLE 对象字段中的 Access table 中的图像插入到 Outlook html 电子邮件的正文中。

我正在使用字符串变量 strBOD:

构建 html
strBOD = strBOD & "<tr>" & "<img src=""smiley.gif"" alt=""Smiley face"" height=""42"" width=""42"">" & "</tr>"

我需要用 OLE 对象替换上面示例中的 "smiley.gif"。

您必须将图像存储在任何人都可以快速访问的地方。否则,您将不得不使用嵌入的图像构建 MIME 消息,这更复杂并且可能使消息膨胀。

我们使用Imgur来存储图像。这是免费的,快速的,并且 运行 "forever".

这是我签名时使用的文件示例:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="da" charset="iso-8859-1">

<head>
    <title>E-mailsignatur Cactus Data ApS</title>
</head>

<body style="font-family: calibri, 'segoe ui', helvetica, arial, sans-serif">

    <span style="font-size: 11pt">
        Venlig hilsen / Best regards / Freundlichen Grüßen<br>
        Gustav Brock
    </span>
    <hr>
    <p style="text-align: center; margin-top: 10px; margin-bottom: 0px;">
        <img src="https://i.imgur.com/HbdRTBD.gif" alt="Cactus Data ApS" title="Cactus Data ApS" /><br>
        <span style="font-size: 9pt;">
            Kalkbrænderiløbskaj 4 A · 2100 København Ø · Danmark<br>
            CVR/VAT: DK12002696 · Telefon: +45 39 29 49 48 · E-mail: <a title="gustav@cactus.dk" href="mailto:Gustav%20Brock%20%3cgustav@cactus.dk%3e?subject=Re:%20E-mail">Gustav Brock</a>
        </span>
    </p>
    <hr>

</body>
</html>

完成并仔细测试后(非常重要,因为 Outlook 的呈现方式与普通浏览器不同),创建 VBA 将重新创建它是一件简单的事情。

或者,也可以像我们一样,将完整的 HTML 存储在注释(长文本)字段中,并在创建电子邮件时检索它。

使用 Outlook 对象模型?参见 Including Pictures in an Outlook Email

请记住,OLE 对象无法插入到 HTML 邮件中 - 您需要将 OLE 对象转换为图像并将其添加为附件,或者邮件必须为 RTF 格式, 但随后插入 OLE 对象并不适合胆小的人。