如何将动态创建的Pdf文档作为附件发送到电子邮件中 [英] how to send dynamic created Pdf document as attachment in email
问题描述
我找到了创建pdf文件的文章
http://www.aspdotnet-suresh.com/2013/05/aspnet-export-webpage-with-images-to.html [ http://csharpdotnetfreak.blogspot.com/2009/10/send- email-with-attachment-in-aspnet.html [ ^ ]
我也找到这篇文章.
http://www.aspdotnet-suresh. com/2012/09/how-to-send-gridview-in-email-body-in.html [
i find out an article to create pdf file
http://www.aspdotnet-suresh.com/2013/05/aspnet-export-webpage-with-images-to.html[^]
also i find an article to send email as smtp mailing in asp.net c#
http://csharpdotnetfreak.blogspot.com/2009/10/send-email-with-attachment-in-aspnet.html[^]
i also find this article also..
http://www.aspdotnet-suresh.com/2012/09/how-to-send-gridview-in-email-body-in.html[^]
i need to send the dynamically generated pdf as attach file and send to specified email address.
推荐答案
好吧,这很简单.
- 通过MemoryStream将pdf放入管道
Ok, that''s simple.
- Pipe the pdf through a MemoryStream
MemoryStream ms = new MemoryStream();
Document doc = new Document(PageSize.A4, 10f, 10f, 100f, 0.0f);
//require custom parsers? add here.
PdfWriter writer = PdfWriter.GetInstance(doc, ms);
doc.Open(); //open doc for editing
//do layout
//doc.Add(new Paragraph("First Paragraph"));
//doc.Add(new Paragraph("Second Paragraph"));
writer.CloseStream = false; //important
doc.Close(); //build the doc.
memoryStream.Position = 0; //reset stream... important
mail.Attachments.Add(new Attachment(ms, "filename.pdf"));
smtp.Send(mail);
^ ]
请参阅此链接
http://www.aspsnippets.com/Articles/Generate-Create-PDF-and-send-as-email-attachment-in-ASPNet.aspx
Pls Refer this Link
http://www.aspsnippets.com/Articles/Generate-Create-PDF-and-send-as-email-attachment-in-ASPNet.aspx
这篇关于如何将动态创建的Pdf文档作为附件发送到电子邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!