在c++builder中使用indy9组件,想要在邮件体内嵌入一个jpg图片,不用超链接的方法怎么实现。
使用的是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中怎么处理