开发者

Delphi to display embedded image in outlook msg

I am reading outlook msg files in Delphi 2010 and displaying the html body of a message in a twebbrowser. It does not however display the embedded image. Hot to display embedded images in outlook me开发者_开发问答ssage? I am using the imported object library.


Embedded images in HTML mail come with src="cid:xx" attribute where xx is the content ID of the image part (Content-Type: application/octet-stream; Content-Disposition: inline) in the multi-part MIME message. You could decode and save that part to a temporary file and fix up the src attribute of the img element to point to the temporary image file. An alternative to "serve" images to the browser through an asynchronous pluggable protocol is described here.


You could use the IHTMLDocument2 interface to do the work for you: (see: http://k210.org/delphi/internet/23/ - create IHTMLDocument2 runtime)

(note: msg = the mail message)

var
   slImages : TStringList;
   ADoc     : IHTMLDocument2;
begin
   slImages := TStringList.create;
   try
      ADoc  := CreateAndLoadIHTMLdoc2AtRuntime(sBody);
      sBody := ConvertHTMLToHTMLWithEmbeddedImages(Adoc, slImages);

      if (slImages.count=0) then
         msg.HTMLBody:= sBody
      else // add attachments + set cid's in this routine   
         SetupEmbeddedImages(msg, sBody, slImages);

   finally
      freeandNil(slImages);
   end;
end;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜