Delphi在outlook msg中显示嵌入图像

发布于 2024-11-14 20:02:00 字数 116 浏览 1 评论 0原文

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱娆 2024-11-21 20:02:00

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

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.

爱冒险 2024-11-21 20:02:00

您可以使用 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;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文