10

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?

hawbsl
  • 15,313
  • 25
  • 73
  • 114

4 Answers4

6

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.

Community
  • 1
  • 1
user56reinstatemonica8
  • 32,576
  • 21
  • 101
  • 125
  • 1
    is this really tested and accepted as answer. i do the same but not embedded as cid or base64 but instead as a url to my local images in outlook 2013 – Iman Nov 29 '13 at 18:38
6

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.

Undefined
  • 11,234
  • 5
  • 37
  • 62
  • 4
    Outlook doesn't support embedded image. – Martin Apr 22 '13 at 05:46
  • @Martin I clearly stated in my answer that not all email clients are supported. If you follow the link it goes into more detail to explain which clients support base64 encoding and which ones dont. – Undefined Apr 22 '13 at 06:30
  • @Sam - Correct, but I am afraid the question is about Outlook. – Martin Apr 22 '13 at 12:48
  • @Martin As explained in my answer. If you check the updated link you will find that embedded images work in Outlook 2003. As the version is not specified in the question this could be what the OP is asking for. – Undefined Apr 22 '13 at 15:23
0

For the last part of your question, "generating a cid/contentid" I know the only way is useing outlook itself (or Word as a text editor of Outlook) to get that.

I had faced this problem when I needed to insert our company logo beside my signature text on the email.

So, open Microsoft Outlook (office 2016 im ny case) go to File > Options > Mail > Compose Messages > Signatures button

Insert/Embed image by Signature Edirot

or inside the Outlook New Message windows, go Insert > Picture

Insert/Embed image by Outlook New Mail Edirot

Bobbiz
  • 43
  • 1
  • 4
-1

If you are using html to make your whole email, you can search google for the same image, and put this in there:

<img src="http://www.google.com/intl/en_ALL/images/logos/images_logo_lg.gif" alt="picture1" />

You can also, use photobucket to host images (if you have to). Basically, you HAVE to have a source for the image.