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;
    

     

  • 相关阅读:
    题解 P1587 【[NOI2016]循环之美】
    PKUSC2019颓废记
    使用ImageIO.write上传二维码文件时候,提示系统找不到指定路径
    rt.jar包添加源文件只需要关联到已安装对应jdk目录下source.zip源码文件即可
    Kali Linux安装中文输入法
    性能测试(一)——理发店模型
    瑜伽,不仅仅是瑜伽,敬艾扬格大师
    为什么想做测试,我的测试开端
    责任链模式-Chain of responsibility
    后缀数组-基础
  • 原文地址:https://www.cnblogs.com/pengshaomin/p/4750720.html
Copyright © 2011-2022 走看看