send email vs 2005

Bill Humphrey

Active member
Joined
Apr 10, 2008
Messages
35
Programming Experience
Beginner
I've upgraded a VS2003 web app to VS 2005, this is the code I used to use to send email for 2003. I'm not sure how to convert this to send email in 2005 can anyone help?



email.To = "MyValidEmailAddress"

email.From = "UsersValidEmailAddress"

email.Body = "A body of text"

email.Subject = "A line of text"

email.BodyFormat = Web.Mail.MailFormat.Text

System.Web.Mail.SmtpMail.SmtpServer = "127.0.0.3"

System.Web.Mail.SmtpMail.Send(email)
 
SystemNetMail.com has excellent examples.

VB.NET:
		Dim mm As New MailMessage()

		mm.From = New MailAddress("FromAddress@domain.com", "Display Name")
		mm.To.Add(New MailAddress("ToAddress@domain.com", "Display Name"))
		mm.CC.Add(New MailAddress("CcAddress@domain.com", "Display Name"))
		mm.Bcc.Add(New MailAddress("BccAddress@domain.com", "Display Name"))

		mm.Subject = "Some subject"
		mm.Body = "Message body"
		mm.IsBodyHtml = False

		mm.Attachments.Add(New Attachment("C:\Temp\Somefile.txt"))

		Dim smtp As New SmtpClient("smtpserver.domain.com", 25)
		smtp.Send(mm)
 
Back
Top