i am trying to read a html file and convert it to pdf using itexsharp and send it as attachment by email :
this is the client side code
<form id="form1" runat="server">
<div>
<img alt="" src="C:\Users\Intern\Documents\Visual Studio 2008\Projects\highChart\highChart\images\279.gif" id="myImg" />
</div>
</form>
server side code
Imports iTextSharp
Imports iTextSharp.text.pdf
Imports iTextSharp.text
Imports System
Imports System.Text
Imports System.IO
Imports System.Net.Mail
Imports System.Net
Imports iTextSharp.text.html.simpleparser
Partial Public Class imagePdf
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
Me.Page.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.[End]()
Dim file As (( i don't know what to add here ))
Dim message As New MailMessage()
message.From = New MailAddress("testApp@somewhereelse.com")
message.To.Add(New MailAddress("anotheraddres84@hotmail.com"))
message.Subject = "pdf "
message.Body = "pdf attached "
Dim data As New Attachment(File)
message.Attachments.Add(data)
Dim client As New SmtpClient()
client.Host = "smtp.gmail.com"
client.Credentials = New NetworkCredential("email", "password")
client.EnableSsl = True
client.Port = 587
client.Send(message)
End Sub
End Class
Each part of this code works fine, i.e. the pdf works, email is fine but how can I use the pdf file as my attached file?