Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 62,013 times

Related Categories

Sending Email With an Attachment

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 = "noone@nobody.com"
oMsg.To = "someone@somewhere.com"
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)

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments