Replace cid:image refrences in email body with Base64 encoded string from another file

那年仲夏 提交于 2019-12-11 14:57:35

问题


I have been tasked with writing an email archiving application. With lots of help from other SO questions and answers, I have succesfully saved the body of the email using Indy10 in Delphi 10.2.3, and it's image attachments as Base64encoded text files.

The body of an email with inline images contains strings like this:

<img width=360 height=153 id="Picture_x0020_8" src="cid:image002.png@01D4F3AE.C0AE8970">

And of course, the base64 encoding for that image looks like this:

data:image/x-png;base64,
iVBORw0KGg...Jggg==

My first question is about cr_lf. I have cr_lf just after base64, and at the end of the file (last 2 bytes). Is this correct for what I want to do?

Now I have to replace the <image width=360..8970"> with the base64encoded image text - and after that, save the new body to the archive, of course.

I can easily delete <image width=360..8970"> part from the body file, and then I want a simple way to insert the contents of the base64 txt file into that file at the right place.

I'll accept references to other SO questions I might have missed that do similar things. I haven't found anything in Delphi that helps me do this.

Thanks

来源:https://stackoverflow.com/questions/55823732/replace-cidimage-refrences-in-email-body-with-base64-encoded-string-from-anothe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!