• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

delphi发送html带附件邮件

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
var
  html: TIdText;
begin
  if not SMTP.Connected then
    SMTP.Disconnect();
  try
    SMTP.Connect;
    try
    if SMTP.Authenticate then //验证
     begin
       EMessage.Recipients.EMailAddresses := FUser;
       EMessage.ClearBody;//清空正文
       html:= TIdText.Create(EMessage.MessageParts);
       EMessage.Subject:='Nest MAC Traceability Report';
       html.ContentType := 'text/html;charset=gb2312';
       html.ContentTransfer := '7bit';
       EMessage.ContentType := 'multipart/alternative';
       html.Body.Add('Dear Sir:');
       html.Body.Add('');
       html.Body.Add('Mac address Status');
       html.Body.Add('<html>');
       html.Body.Add('<head>');
       html.Body.Add('<meta http-equiv="Content-Type" content="textml; charset=big5">');
       html.Body.Add('<meta name="GENERATOR" content="Microsoft FrontPage 4.0">');
       html.Body.Add('<meta name="ProgId" content="FrontPage.Editor.Document">');
       html.Body.Add('<title>Nest MAC Traceability Report</title>');
       html.Body.Add('<body>');
       html.Body.Add('<table>');
       html.Body.Add('<tr>Date : </tr>');
       html.Body.Add('<tr>');

       html.Body.Add('<table bordercolorlight="black"  width="50%" border="3" bordercolor="black" cellspacing="0" >');
       html.Body.Add('<tr bgcolor="#31C4F5" align="Center">');
       html.Body.Add('<td width="500">Image</td>');
       html.Body.Add('<td width="500">Releasing date</td>');
       html.Body.Add('<td width="700">Total released Qty</td>');
       html.Body.Add('<td width="1000">Cumulative Consumed Qty</td>');
       html.Body.Add('<td width="500">Leftover Qty</td>');
       html.Body.Add('<td width="700">Cumulative scrap Qty</td>');
       html.Body.Add('</tr>');
       html.Body.Add('<tr>');
       html.Body.Add('</tr>');
       html.Body.Add('</table>');
       html.Body.Add('</tr>');
       html.Body.Add('</table>');
       html.Body.Add('</body>');
       html.Body.Add('<ml>');


       EMessage.From.Address :=  SMTP.Username;//发送人
       EMessage.From.Name    := '彭工';

       if FileExists(FAttacFile) then
       begin
          AttachmentFile := TIdAttachmentFile.Create(EMessage.MessageParts, FAttacFile);
          AttachmentFile.ContentType := 'text/plain';
       end;

        SMTP.Send(EMessage);
     end;
    finally
       FreeAndNil(html);
       FreeAndNil(EMessage);
       if Assigned(AttachmentFile) then
        FreeAndNil(AttachmentFile);

       SMTP.Disconnect();
    end;
  except ON E: Exception do
       raise Exception.Create(E.Message);

  end;
end;

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Matlab2016a运行报错NosupportedcompilerorSDKwasfound发布时间:2022-07-18
下一篇:
Linux下MATLAB安装及使用发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap