3

I know similar questions have already been asked but the answer is almost always the same: you need to share the image on a server and link to it from within the email.

For my purpose I cannot do that.

The image needs to be personalized for each user I send an email to (so the email will be dynamically generated for each user and will not always be the same. I cannot share the image -- since it will change but also for avoiding disclosure of users' information).

Have you ever encountered this scenario? Should I go with attachments or base64 encoding of images? Thoughts/experiences?

Ruskin
  • 5,721
  • 4
  • 45
  • 62
Cyan
  • 1,068
  • 1
  • 12
  • 31
  • I do think this is a valid question, but could you please specify how the image will be personalized? Will you generate them yourself? – Joeytje50 May 26 '14 at 14:30
  • They will be taken from a DB, but they will be different for each user. – Cyan May 26 '14 at 15:31
  • and are you sending this from an ESP like exact target? Or from a personal domain/host? – zazzyzeph May 27 '14 at 15:33
  • Whatever you do make sure that the content is supplied as text too - e.g. in alt tag - as many people view emails without images. – Ruskin May 29 '14 at 09:04
  • Why can you not save each of the images on a server - that could be a solution - just create one image per email with a naming convention e.g. guids? If there is sensitive information in the email, is email the correct vector to use - email is not secure. – Ruskin May 29 '14 at 09:06

2 Answers2

3

The HTML body must refer to the images using the content id (cid): <img src="cid:xyz">, where xyz is the value of the attachment content id (Content-ID) MIME header.

If you are creating the message directly in the MIME format, make sure the attachment is added to the message and its Content-ID MIME header is properly set. If you are Outlook Object Model or MAPI, you must set the PR_ATTACH_CONTENT_ID property on the image.

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

Since HTML5 allows base64 encoded images inline, this might be the easiest way to go. Check the following source: http://www.bigfastblog.com/embed-base64-encoded-images-inline-in-html

You should consider that not all mail clients might support HTML5 and therefore attaching the image and referencing it in your code may be the harder but better choice. Unfortunately I have no experience with that.

Edit: This tutorial looks promising, but I have not tried it: http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-in-HTML-Email-P113.html

Merlin Denker
  • 1,380
  • 10
  • 15
  • The main concern with the base64 approach is that it seems that the data transferred will be bigger than if we would use a binary file attached according to this thread http://stackoverflow.com/questions/11402329/base64-encoded-image-size. How will email clients react to this? This is certainly a concern over the mobile netwroks. – Cyan May 26 '14 at 15:30
  • 3
    Cannot use that in Outlook - Word renders HTML images in Outlook, not IE. And Word does not support embedded images. – Dmitry Streblechenko May 26 '14 at 20:57
  • @DmitryStreblechenko You mean: Word renders HTML emails in Word ... :) – yunzen May 30 '14 at 09:31
  • 1
    No, I mean Word renders HTML in Outlook - it has a shared component that is used in both Outlook and Word. IE is not used. – Dmitry Streblechenko May 30 '14 at 13:37