Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed an image into an Outlook HTML email message?

We have a Winforms application which supports dragging and dropping chunks of HTML into Outlook (HTML) mail messages.

Chunks of text are fine.

But how do we proceed with images? Let's assume we don't want to host the images online but instead we want to send them with the email message. Assume also that we do want to see the image inline, not as an attachment (where the recipient's email client supports that, of course).

If you look at the HTML source of an Outlook message there are "cid" tags for images (which point to the image as an attachment I guess), but how do we go about generating a cid/contentid?

like image 337
hawbsl Avatar asked Mar 13 '12 16:03

hawbsl


People also ask

How do you embed an image in HTML?

The HTML <img> tag is used to embed an image in a web page. Images are not technically inserted into a web page; images are linked to web pages. The <img> tag creates a holding space for the referenced image. The <img> tag is empty, it contains attributes only, and does not have a closing tag.

Can you embed HTML in Outlook email?

You can inject HTML code into the message body via the Insert as Text option; tab Insert-> (Attach) File-> select the created htm-file-> press the down arrow on the Insert button-> Insert as Text.


2 Answers

If a manual step in the process is an option, you can do it like this:

  1. create the HTML automatically or manually as a saved HTML file, with <img> tags that link to locally-saved image files
  2. attach the HTML to an Outlook email using the 'Insert as text' option tucked away under the down-arrow on the "Insert" button when selecting the HTML file as an attachment.

This populates the HTML email with the HTML from the file and embeds all images. I believe this tool uses Base64 encoding to embed the images as described in Sam's email.

Depending on the workflow, this method might be easier than converting images to Base64 yourself.

Note that this method only works in Outlook for Windows, not Outlook for Mac.

like image 179
user56reinstatemonica8 Avatar answered Sep 24 '22 22:09

user56reinstatemonica8


You can embed images in a html email using a base64 encoder. Its quite complicated but you basically encode the image as a text string in the email which is then interpreted.

This does not work in all email clients though.

Take a look at this and see if its what your looking for:

http://www.campaignmonitor.com/blog/post/1761/embedding-images-in-email/

EDIT

The updated campaign monitor post on the clients which work with base64 images.

like image 32
Undefined Avatar answered Sep 20 '22 22:09

Undefined