Search code examples
htmlemailoutlookhtml-emailwebmail

What is the recommended way for sending personalized images in html emails?


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?


Solution

  • 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.