Вопрос

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 message? 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;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top