zoukankan      html  css  js  c++  java
  • 【Vegas原创】asp.net页面作为邮件正文发送

    此类页面的发送要用htmlWriter类来解决。

    如:一个asp.net页面只有一个Datagrid。现在要把Datagrid显示的信息以邮件正文方式发送出去。

    在此页面的后台页面Page_Load函数中添加:

    //Mail
                MailMessage mailObj=new MailMessage();
                StringWriter sWriter
    =new StringWriter(); 
                HtmlTextWriter htmlWriter
    =new HtmlTextWriter(sWriter); //以这个流类作为参数来进//行传输数据。
                DataGrid1.RenderControl(htmlWriter);    
                mailObj.From
    ="**"//发信人的邮件地址
                mailObj.To="**";   //收信人的邮件地址
            
    //    mailObj.Bcc="xxxx@xxx.com";  //收取密件副件人的地址
                mailObj.Subject="FEOL Daily Report~";  //邮件的主题
                mailObj.Body=sWriter.ToString();  //将流类的内容作为邮件的正文部分
                mailObj.BodyFormat=MailFormat.Html;  //格式化为html格式
                string attaches = @"f:\KPI\FEOLScrap.xls"//附件
                MailAttachment myAttachment = new MailAttachment(attaches); //这里以附件作为参数
                mailObj.Attachments.Add(myAttachment); 
            
                
    try
                {   
                    SmtpMail.SmtpServer 
    = "**";
                    SmtpMail.Send(mailObj); 
    //调用SmtpMail类来发送邮件
                }
                
    catch(Exception pp)
                {
                    Response.Write(pp.Message);
                }


    喜欢请赞赏一下啦^_^
  • 相关阅读:
    python 3.x 不再提供raw_print()
    php中fileatim,filectime和filemtime函数的区别
    如何将文本以BLOB类型存入数据库并取出
    tomcat启动不了——Error initializing endpoint——java.net.BindException: Address already in use: JVM_Bind
    hdu 2188(巴什博弈入门 )
    hdu 2187(贪心)
    Sentinel数据处理工具包SNAP Python开发环境搭建
    conda 安装包命令
    使用SSH连接WSL
    win10 安装WSL 出现 WslRegisterDistribution failed with error: 0x8000000d
  • 原文地址:https://www.cnblogs.com/amadeuslee/p/3744716.html
Copyright © 2011-2022 走看看