CarlD
CarlD

Reputation: 13

Azure Logic App: How to keep embedded image in email body when forwarding on?

I am setting up a bulk emailing solution combining Logic Apps and SendGrid.

User sends email to a mailbox with attachment of required recipients > Logic App reads email > LA resends 'Body' via SendGrid for each recipient.

This works fine with a plain email. However, when an image is embedded within the body Outlook uses Content-IDs.

Currently the body of the email just says a broken image symbol.

How can the images be kept for the re-sending on?

enter image description here

Upvotes: 1

Views: 3551

Answers (1)

George Chen
George Chen

Reputation: 14334

If you want to implement it directly, it could be done. Because if you try to get the mail body you will find it's like below picture.

enter image description here

The body is escaped mail content and the image content is the contentBytes under attachments it's a base64 code.

So if you want to send a image from another mail you have to get the base64 code embed it to your mail. I use the outlook trigger to test it and send with sendgrid, the content will be like this code.

This is test email <br>\n<img src=\"data:image/jpeg;base64,@{triggerBody()['attachments'][0]['contentBytes']}\">

enter image description here

enter image description here

I test this way could send the image, and it could be seen in the mail. If this is not what you want please let know.

Upvotes: 1

Related Questions