0
我使用下面的代码来生成PDF并将其保存到某个位置。将附带生成的PDF作为电子邮件发送出去是否可能?我假设电子邮件编码需要在HTML中完成?因为它会在网络服务器上。这可能吗?发送电子邮件与生成PDF作为附件?
Dim Doc1 As New Document
Dim path As String = "\\Server\Folder" + Session("Username") + "\"
If (Not System.IO.Directory.Exists(path)) Then
System.IO.Directory.CreateDirectory(path)
End If
Dim myUniqueFileName = String.Format("{0}.pdf", random)
Dim pdfWrite As PdfWriter = PdfWriter.GetInstance(Doc1, New FileStream(path & myUniqueFileName, FileMode.Create))
' Dim ev As New itsEvents
' pdfWrite.PageEvent = ev
Doc1.Open()
Dim test As String
test = Session("PDF")
Dim imagepath As String = Server.MapPath(".") & "/images/Header.png"
Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(imagepath)
image.ScalePercent(70.0F)
' image.SetAbsolutePosition(36.0F, 36.0F)
Doc1.Add(image)
Doc1.Add(New Paragraph(test))
Doc1.Close()
你进去看了'System.Net.Mail'命名空间? http://msdn.microsoft.com/en-us/library/System.Net.Mail.aspx –
是的,但我不知道我将如何抓住附件? – user1342164
http://msdn.microsoft.com/en-us/library/system.net.mail.attachment.aspx有构造函数需要一个字符串,有些需要流。你应该能找到一个适合你的人。 –