在c++builder中使用indy9组件,想要在邮件体内嵌入一个jpg图片,不用超链接的方法怎么实现。

yusinuo 2011-01-31 03:44:41
使用的是indy9组件。怎样将一个图片作为邮件体的一部分发送出去?不是单单作为附件,而是要显示在邮件体里面的.我没多少分数,都给大家,希望大家帮帮忙,苦恼好几天了.
看到delphi的代码是这样
if (relatedAttachmentList.Count>0) and (not_relatedAttachmentList.Count>0) then
begin
with TIdText.Create(Msg.MessageParts, nil) do begin
ContentType := 'multipart/alternative';
ParentPart :=-1;
end;
with TIdText.Create(Msg.MessageParts, nil) do begin
Body.Text :=tempstr2;
ContentType := 'text/html';
ParentPart := 0;
end;
for i:=0 to relatedAttachmentList.Count-1 do
with TIdAttachmentFile.Create(Msg.MessageParts, relatedAttachmentList.Strings[i]) do begin
ContentID := CIDGet(relatedAttachmentList.Strings[i]);
ContentType := 'image/*';
ContentDisposition := 'inline';
ParentPart := 0;
end;
还有看到一个帖子是这样
IdHtml := TIdText.Create(MessageParts);

IdHtml.ContentType := 'text/html;charset=gb2312';

IdHtml.ContentTransfer := '7bit';

IdHtml.Body.Add(' <html>');

IdHtml.Body.Add(' <head>');

IdHtml.Body.Add(' <title>' + StrPas(MailSubject) + ' </title>');

IdHtml.Body.Add(' </head>');

IdHtml.Body.Add(' <body title="' + References + '">');

IdHtml.Body.Add(' ' + StrPas(MailContent) + ' <br>');

if (not IsCustom) and FileExists(StrPas(JpgFileName)) then

IdHtml.Body.Add(' <img src="cid:' + StrPas(PicID) + '" alt="' + ExtractFileName(StrPas(JpgFileName)) +

'" name="' + ExtractFileName(StrPas(JpgFileName)) + '" title="">');

IdHtml.Body.Add(' </body>');

IdHtml.Body.Add(' </html>');

end;

if FileExists(StrPas(JpgFileName)) then

begin

Att := TIdAttachmentFile.Create(MessageParts, StrPas(JpgFileName));

Att.ExtraHeaders.Values['Content-ID'] := StrPas(PicID);

Att.ContentType := 'image/jpg';

end;

if FileExists(StrPas(Attachment)) then

begin

Att := TIdAttachmentFile.Create(MessageParts, StrPas(Attachment));

end;

end;

请问在c++builder中怎么处理
...全文
118 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧