I am using iTextSharp to generate pdf file but i want to send that pdf to a email address. How can send generated pdf file to email using my given code. Please help me.
How to send pdf in email using MailSender() function.
Using sw As New StringWriter()
Using hw As New HtmlTextWriter(sw)
repeaterName.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 50.0F, 50.0F, 40.0F, 50.0F)
Dim writer As PdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr)
pdfDoc.Close()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=" + ViewState("BillNo").ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Write(pdfDoc)
Response.End()
End Using
End Using


Shubham KumarRank #621 · 3.8K reputationPosted Mar 3, 2016, 12:35 AM EST
Mohammad AmanRank #4,571 · 337 reputationPosted Mar 3, 2016, 1:12 AM EST
Shubham KumarRank #621 · 3.8K reputationPosted Mar 3, 2016, 1:18 AM EST