asp.net 带附件的邮件

                string url = "http://10.1.1.0/ProcessWeb/Page/ProcessForm.aspx?smdname=AdminSerApplication_SmartDS&formname=AdminSerApplication_Form&procname=AdminSerApplication_Process&step=view&procinstid=" + procinstid;

                XmlDocument xml = new XmlDocument();
                xml.LoadXml(xmlStr);

                //获取保存路径
                string outputFileName = "";
                string path = ConfigurationManager.AppSettings["UpLoadFilePath"];
                DateTime now = DateTime.Now;
                string time = now.Year.ToString() + now.Month.ToString() + now.Day.ToString() + now.Hour.ToString() + now.Minute.ToString() + now.Second.ToString() + now.Millisecond.ToString();
                string fileName = serialNumber + ".pdf";
                string newfileName = path + fileName; //文件保存路径


                文件名
                outputFileName = System.IO.Path.Combine(path, fileName);
                EO.Pdf.HtmlToPdf.Options.HeaderHtmlFormat = serialNumber;
                EO.Pdf.HtmlToPdf.Options.FooterHtmlFormat = "流程管理系统";
                EO.Pdf.HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A5;
                EO.Pdf.HtmlToPdf.Options.NoLink = false;
                HtmlToPdf.ConvertUrl(url, outputFileName);


                PdfDocument doc = new PdfDocument(outputFileName);
                doc.Security.Disallow(PdfDocumentPermissions.Printing);
                AcmRender render = new AcmRender(doc);
                render.BeforeRenderPage += new AcmPageEventHandler(BeforeRenderPage);
                AcmContent content = new AcmContent();
                render.Render(content);
                doc.Save(outputFileName);

                
                MailMessage msg = new MailMessage();
                string mailFrom = "11111@qq.com";
                string MailAdminPwd = "XXXX"; 
                msg.From = new MailAddress(mailFrom);         //发件人的Email地址
                string SendMailUser = "123@qq.com";                     
                msg.To.Add(new MailAddress(SendMailUser));

                string userName = mailFrom.Substring(0, mailFrom.IndexOf("@"));      //取发件人Email用户名
                msg.Subject = Title;  //邮件标题
              msg.Body = Content;//邮件内容
                msg.IsBodyHtml = true;  //邮件正文格式
                msg.Priority = MailPriority.Normal;//优先级别有3个级别 Normal 一般 High 最高 Low 最低
                SmtpClient c = new SmtpClient(); //邮件发送类对象  
                c.Host = "10.1.1.1";//smtp协议地址
                c.Port = 25;
                c.EnableSsl = false;
                c.UseDefaultCredentials = false;

                c.Credentials = new NetworkCredential(userName, MailAdminPwd);//自己的用户名及密码

                msg.Attachments.Add(new Attachment(outputFileName));
                //发送邮件
                c.Send(msg);
                msg.Dispose();   //释放资源
                c.Dispose();     //释放资源
                

  

转载于:https://www.cnblogs.com/hsdt/p/7458250.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值