Outlook add-in - convert inline images into base64 and replace the image in the body

79 Views Asked by At

I have an outlook add-in which takes the body of an email finds the inline images gets the base64 encoding and then replaces the src of the inline image to base64 version, this is then sent to an api and the body is saved in a db.

I am doing this by getting the all the Attachments using getAttachmentsAsync() then getting all the images in the email body then matching the names of the images with the attachment names.

I have noticed that some inline images on Outlook desktop app show like the below and the getAttachmentsAsync method does not return the cid so there is no way to match them

<img contenttype="image/png" data-outlook-trace="F:1|T:1" src="cid:4f9c247a-820d-4ec2-ade3-1bc8783b067c" style="max-width: 1436px;" size="3027"/> 

Does anyone have any ideas how i can achieve this or another way of doing/dealing with this ?

Thanks, Ritesh

MORE INFORMATION

This is not happening for every inline/embeded image only for some

This is the image src

Image src = cid:9CD03B115934420393C4E38F215995CC

When I call getAttachmentsAsync() this is returned, nothing matches the cid of the image

getAttachmentsAsync output

1

There are 1 best solutions below

2
Eugene Astafiev On

When you don't have the PR_ATTACH_CONTENT_ID property set on the attachment you need to search for the attachment name specified for the cid attribute .