读书人

发送带图片的邮件解决办法

发布时间: 2012-03-05 11:54:01 作者: rapoo

发送带图片的邮件
小弟要做一个发送邮件的程序,邮件里面有图片。我现在是先做了一个html的页面,然后用webbrowser来显示这个页面,然后发送 (wb1.Document as IHTMLDocument2).body.outerHTML 的内容,但接收到的邮件只有文字部分,图片的地方是空白。请问大家怎么解决啊?

另外,我发的页面里面是一些固定的表格,只有某些数字是变量,所以我想做一个模板,然后通过变量取值来形成新的页面发送出去。所以我做了一个html的模板,但不知道在delphi中要如何替换那些变量。或者大家有没有更好的办法?谢谢!

[解决办法]
接收到的邮件中图片的路径是什么,路径指定的地方有图片吗?
需要把图片保存到本地再显示出来,
Outlook要显示的图片地地也会有的
[解决办法]
Simply sending HTML won't work as you see it in browsers:

1. You will need to write code to send inline images.
2. Change your HTML IMG tag to tell the email browser that it is inline image
<img src="cid:my.jpg" />
3. in case of you are using Indy then you will have to create attachment like this

Delphi(Pascal) code
  .......  imgpart := TIdAttachment.Create(email.MessageParts, filename);  imgpart .ContentType := 'image/jpeg';  imgpart .FileIsTempFile := true;  imgpart .ContentDisposition := 'inline';  imgpart .ExtraHeaders.Values['content-id'] := 'my.jpg';  imgpart .DisplayName := 'my.jpg';  ...... 

读书人网 >.NET

热点推荐