zoukankan      html  css  js  c++  java
  • delphi发送html带附件邮件

    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;
    

     

  • 相关阅读:
    电脑开机自动上线(电脑开机之后自动将电脑的远程端口映射到服务器,可以通过其他设备进行连接,实现随时访问自己的电脑)
    批处理(bat)用来监测Windows网络状态脚本
    js取消点击事件
    uni-app 几个实用的功能
    前端几个比较方便的正则验证
    element.ui时间选择器
    Vue pc端项目打包后在nginx中无法正常浏览,点击页面出现404
    微信小程序之选项卡的实现方法
    文本溢出显示省略号
    分享几道前端面试题(3)
  • 原文地址:https://www.cnblogs.com/pengshaomin/p/4750720.html
Copyright © 2011-2022 走看看