This code demonstrates how to send an email in VB.NET with an attachment. It currently attaches the file "C:\myattachment.zip" - in order to work, this file must obviously exist!
Dim oMsg As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage()
oMsg.From = "[email protected]"
oMsg.To = "[email protected]"
oMsg.Subject = "Email with Attachment Demo"
oMsg.Body = "This is the main body of the email"
Dim oAttch As MailAttachment = New MailAttachment("C:\myattachment.zip")
oMsg.Attachments.Add(oAttch)
SmtpMail.Send(oMsg)
Comments