问题
I just know I must save the images in a temp folder and then use them on Htmlviewer .
But suppose we have an email which contains 5 pictures, so html viewer provides 5 empty frames for the images , some of them are located before the text body, some of them are at the middle and some at the end of the email body . Now How can I define which frame should contain which picture ! ? and how to insert them to the Html viewer ?!.
(is there any way to do all job in a memory stream ? I mean without saving the images in a folder )
回答1:
The benefit to using THtmlViewer
is that you do not need to save the images to file beforehand. The component can request the image data from you when needed, via the OnImageRequest
event. You can supply the data from any source you have available. HTML emails use cid:
URLs to refer to resources inside the email itself, usually attachments. When the component asks you for such a URL, you can pull the coresponding data from TIdMessage
directly. TIdMessage
supports loading emails completely into memory without using any temp files at all. You do that by creating an instance of the TIdAttachmentMemory
class in the TIdMessage.OnCreateAttachment
event.
PBear released THtmlViewer
into the public domain a few years ago and it is now being maintained as an open source project on Google Code. There are several demos available, include a couple that use Indy 9. You should be able to update them to Indy 10, which is what XE2 uses.
来源:https://stackoverflow.com/questions/9143306/how-to-display-an-email-images-on-pbear-html-viewer-component