Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference attached images from html email body in CRM2011

I would like to create an email with an embedded image from within a CRM2011 plug-in. So the plan is to create an email entity, add an attachment entity to it and include an image element like the following in the email html body:

<img src="cid:[email protected]" />

The problem is that I do not know how the content-id is generated by CRM2011.

The first part (image001.png) is obviously the file name of the attachment. But where does the other part (@01CBDDB1.BACB59F0) come from? Is there a way to derrive this part based on the fields of the attachment entity?

Cheers, Nang.

like image 233
nang Avatar asked Nov 14 '22 18:11

nang


1 Answers

Looking at the raw MIME that is delivered to the email client, when the attachments are added to the email by the email router there is no ContentID specified and I can't see anyway of adding one through the SDK ActivityMimeAttachment.

The only alternative I can think of, if your writing server code, is to send the email directly to your SMTP server, that way you can add your content id for your attachments and reference them in the image. You could use OpenPop to relay the message.

Another alternative I've tried is to embed the image as data in the img tag as base64encoded. While this works, it seems that Outlook for the mac and windows does not render the image correctly when view the message. If you view click the view message in browser, html message displayed correctly in the browser. But that's not a lot of use. http://en.wikipedia.org/wiki/Data_URI_scheme#Web_browser_support

like image 177
Simon Avatar answered Jan 05 '23 22:01

Simon