indy10发送网页

KeyLife富翁笔记

作者 : lqcros
标题 : 使用indy10发送网页
关键字:
分类 : 个人专区
密级 : 公开

 

delphi2009 indy10通过
procedure TformMain.butnSendMailClick(Sender: TObject);
var
  html: TStrings;
  filename: string;
begin
  filename := ExtractFilePath(Application.ExeName) + 'YouImg.jpg';
  html := TStringList.Create;
  html.Add('');
  html.Add('');
  html.Add('');
  html.Add('

Hello

');
  html.Add(' '); //这里这个CID是什么意思,还没弄明白。
  html.Add('This is a picture!');
  html.Add('');
  butnSendMail.Enabled := False;
  try
    with mesgMessage do begin
      Clear;
      From.Text := Trim(editFrom.Text);
      Recipients.EMailAddresses := Trim(editTo.Text);
      Subject := Trim(editSubject.Text);
    end;
    with TIdText.Create(mesgMessage.MessageParts, nil) do begin
      ContentType := 'multipart/alternative';
//      ParentPart :=-1;
    end;
    with TIdText.Create(mesgMessage.MessageParts, nil) do begin
      Body.Text := html.Text;
      ContentType := 'text/html';
//      ParentPart := 0;
    end;
    with TIdAttachmentFile.Create(mesgMessage.MessageParts, filename) do begin
      ContentID := filename;
      ContentType := 'image/*';
      ContentDisposition := 'inline';
//      ParentPart := 0;
      ExtraHeaders.Values['content-id'] := ExtractFileName(Filename);
      DisplayName := ExtractFileName(Filename);
    end;
  mesgMessage.ContentType:='multipart/mixed';
//  mesgMessage.SaveToFile('1.txt');
    with smtpSendMail do begin
      Host := Trim(editSMTPServer.Text);
      Connect;
      try
        Send(mesgMessage);
      finally Disconnect; end;
    end;
    Status('Completed');
  finally butnSendMail.Enabled := True; end;
end;

2009-2-22 15:04:32   

查看评语»»»

2009-2-26 11:15:21 

I   copied&pasted   this   code   from   an   existing   unit   I   have,   and   it   should   do   exactly   what   you   want.   The   trick   however   isn't   just   adding   the   image(s)   as   attachment   but   also   telling   OE   or   Outlook   where   to   find   them.   To   do   this,   use   the   "cid:imagename.jpg"   tag   in   your   HTML   code   for   the   images.   Also,   use   the   ExtraHeader   property   to   set   'Content-ID'   to   the   name   of   the   image   as   it 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值