VB.NET
If FileUpload1.HasFile Then
Dim toAddress As String = "you@yourprovider.com"
Dim fromAddress As String = "you@yourprovider.com"
Dim mailServer As String = "smtp.yourprovider.com"
Dim myMailMessage As MailMessage = New MailMessage()
myMailMessage.To.Add(toAddress)
myMailMessage.From = New MailAddress(fromAddress)
myMailMessage.Subject = "Test Message"
Dim fileName As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
Dim myAttachment As New Attachment(FileUpload1.FileContent, fileName)
myMailMessage.Attachments.Add(myAttachment)
Dim mySmtpClient As New SmtpClient(mailServer)
mySmtpClient.Send(myMailMessage)
End If
It's all about Knowledge blog is a Pakistan’s leading Blog offering new techniques, logic, ready made solutions and tools to developers, students, professionals or IT personnel in order to increase their productivity, skills, knowledge. Keep updated and sharpen with new controls, applications, gadgets and tool. This blog also offers free stuff like free e-books, free download able codes, videos, gadgets, controls, tools and consultation.
Tuesday, May 12, 2009
Sending attachment with an email from fileupload control
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment