0

I have to insert an image, stored in an Access table in an OLE Object field, into the body of an Outlook html email.

I am building the html using a string variable, strBOD:

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

I need to replace the "smiley.gif" in the example above with the OLE Object.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Chris
  • 35
  • 10

2 Answers2

0

You must have the image stored somewhere where anyone can reach it fast. If not, you will have to build a MIME message with the embedded image which is more complicated and may bloat the message.

We use Imgur to store the images. This is free, fast, and will run "forever".

Here is an example of a file in use as my signature:

<!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>

When done and carefully tested (very important, as Outlook doesn't render exactly as the common browsers), it is a simple matter to create VBA that will recreate it.

Or, alternatively as we do, store the complete HTML in a Note (Long Text) field and retrieve it when creating the e-mail.

Gustav
  • 53,498
  • 7
  • 29
  • 55
  • But note that most mail clients won't load external images automatically, so the recipient needs to click "load images" (or similar) before the image is shown. – Andre Nov 27 '19 at 13:51
0

Using the Outlook Object Model? See Including Pictures in an Outlook Email

Keep in mind that OLE objects cannot be inserted into HTML messages - you either need to convert the OLE object to an image and add it as an attachment, or the message has to be in the RTF format, but then inserting OLE objects is not for the faint-hearted.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78