Delphi在outlook中显示嵌入式图像

时间:2011-06-08 08:36:26

标签: delphi outlook outlook-object-model

我正在阅读Delphi 2010中的outlook msg文件,并在twebbrowser中显示消息的html正文。但它不会显示嵌入的图像。热门在Outlook消息中显示嵌入的图像?我正在使用导入的对象库。

2 个答案:

答案 0 :(得分:4)

HTML邮件中的嵌入图像带有src="cid:xx"属性,其中xx是多部分MIME邮件中图像部分(Content-Type: application/octet-stream; Content-Disposition: inline)的内容ID。您可以解码并将该部分保存到临时文件,并修复src元素的img属性以指向临时图像文件。通过异步可插入协议向浏览器“提供”图像的替代方法被描述为here

答案 1 :(得分:0)

您可以使用IHTMLDocument2界面为您完成工作: (参见:http://k210.org/delphi/internet/23/ - 创建IHTMLDocument2运行时)

(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;