如何将生成的pdf文件作为附件发送到电子邮件中 [英] How to send generated pdf file as attachment in email

查看:801
本文介绍了如何将生成的pdf文件作为附件发送到电子邮件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在做一个报价项目,当客户填写报价并提交按钮时,填写报价中的详细信息应创建为pdf和pdf文件应该通过邮件作为附件发送。我创建了pdf文件。我需要的是如何通过邮件附件发送创建的pdf文件?



这是我创建pdf的代码





im doing one quotation project in that when the client fill the quotation and submit the button the details in the filled quotation should be created as pdf and the pdf file should be send through mail as an attachment.here i have created the pdf file.what i need is how to send the created pdf through attachment in mail?

this is my code for creating pdf

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition",                  "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();



请告诉我如何将这个pdf文件作为邮件附件发送????


plz tell me how to send this pdf file as attach in mail????

推荐答案

在保存时以pdf格式创建报价,并以简单的方式邮寄。

您可以发送这样的邮件



Create quotation in pdf at the time of saving and the mail it in simple way.
You can send mail like this

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress(txtFromEmailID.Text);
mail.To.Add(txtTOEmailID.Text);
mail.Subject = txtSubject.Text;
mail.Attachments.Add(new Attachment("path of your pdf file"));
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential(txtFromEmailID.Text,txtPassword.Text);
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);





希望对您有所帮助



hope this help you


Refer这些:



http://stackoverflow.com/questions/3294620/how-to-send-generated-pdf-file-as-attachment-in-email-from-c [ ^ ]



http://www.eggheadcafe.com/community/asp-net/17/10317406/how-to-send-mail-with-pdf-attachment .aspx [ ^ ]
Refer these:

http://stackoverflow.com/questions/3294620/how-to-send-generated-pdf-file-as-attachment-in-email-from-c[^]

http://www.eggheadcafe.com/community/asp-net/17/10317406/how-to-send-mail-with-pdf-attachment.aspx[^]


看到这个



http://www.eggheadcafe.com/community/asp-net/17/10317406/how -to-send-mail-with-pdf-attachment.aspx [ ^ ]

http://stackoverflow.com/questions/3294620/how-to-send-generated-pdf- file-as-attachment-in-email-from-c [ ^ ]
see this

http://www.eggheadcafe.com/community/asp-net/17/10317406/how-to-send-mail-with-pdf-attachment.aspx[^]
http://stackoverflow.com/questions/3294620/how-to-send-generated-pdf-file-as-attachment-in-email-from-c[^]


这篇关于如何将生成的pdf文件作为附件发送到电子邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆