Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Embed attached image in email body html via CID

(0) ShareShare
ReportReport
Posted on by 185
 

Hello.

Is it possible to embed an attached image to email body html via the <img> tag with src = "cid:<some content id>"?

My current solution is:

1) Get ActivityMimeAttachments with "image/..." mime type related to the email
2) Get the ContentId property of these attachments
3) Add corresponding <img> tags to email description:

<img src="cid:<contentid value here>" alt = "Some image"/>

After that I save this email and send it via CRM Email router.
Recieved emails contain correct attachments and <img> tags with CIDs, but images aren't displayed in all browsers and email clients. Just empty squares with alt text.

I've googled a solution and found the following KB article: https://support.microsoft.com/ru-ru/kb/2934043. Maybe, this is the source of my problem?

Thanks.

*This post is locked for comments

  • Suggested answer
    Community member Profile Picture
    2 on at
    Embed attached image in email body html via CID
    I am responding to anyone who is struggling with adding images to email body using nodemailer. I had an array of images and wanted to dynamically add them to my email body. I used a loop and then did this  attachments.push({filename:item.name, path:item.m_image, cid:`${item.id}`}), ( note: I declared attachments outside the array then pushed the images into it). For the img tag, I did this <img key=${item.id} src= `cid:${item.id}` /* I used backtips on src, not quotes */ /> and finally I added attachments like this 
    const mailConfig = {
    from: `my email`,
    to: "receiver email",
    subject: 'Order confirmation',
    html: mail,
    attachments: attachments
    }
     
  • Genato Profile Picture
    56 on at
    RE: Embed attached image in email body html via CID

    Hello,

    @Mihir Kadam have you find any solution to this?

    Thank you.

  • Mihir Maruti Kadam Profile Picture
    702 on at
    RE: Embed attached image in email body html via CID

    I have the same requirement. @kate_t Do have the solution ?

  • Kate_T Profile Picture
    185 on at
    RE: Embed attached image in email body html via CID

    Hello Nithya,

    I'm not sure that this post meets my requirements completely. Unless I'm mistaken, Adi's answer is related to incoming emails  (from external senders to CRM) and the image src like "/MicrosoftCRM/Activities/Attachment/...." is an internal CRM url.  My task is embedding images in outgoing emails (from CRM to external recievers). These recievers don't have access to a server where CRM is hosted.  

    Nevertheless I will try this solution.

    Thank you.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
    RE: Embed attached image in email body html via CID

    Hi Kate,

    Please refer the link below:

    https://social.microsoft.com/Forums/en-US/b35caf40-dd8a-4f13-855d-71d9884f05aa/30-embed-images-in-crm-email?forum=crm

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,110 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans