How to send an Email in VB.NET

  • Thread starter Thread starter me
  • Start date Start date
M

me

Hi all,

Does anyone have a simple SendEmail routine?

I want to be able to set the Subject, Send To address, Body and SMTP server
details (server, username, password).

Thanks
 
me said:
Does anyone have a simple SendEmail routine?

I want to be able to set the Subject, Send To address, Body and SMTP
server details (server, username, password).

..NET 1.0/1.1:

'System.Web.Mail' (in "System.Web.dll").

..NET 2.0:

'System.Net.Mail'.
 
This works fine in .NET 2.0 and does not depend on CDO objects. It can be
used with independent providers because you can use authentication.

Dim msg As New System.Net.Mail.MailMessage
Dim smtp As New System.Net.Mail.SmtpClient
Dim addrFrom As New System.Net.Mail.MailAddress("(e-mail address removed)")
Dim addrTo As New System.Net.Mail.MailAddress("(e-mail address removed)")
msg.From = addrFrom
msg.To.Add(addrTo)
msg.Subject = "Subject Text"
msg.Body = "Body Text"
smtp.Host = "smtpserver.provider.com"
smtp.Port = 25
smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
smtp.Credentials = New System.Net.NetworkCredential("isp-username",
"isp-password")
smtp.Send(msg)


Jeroen
 
me said:
Hi all,

Does anyone have a simple SendEmail routine?

I want to be able to set the Subject, Send To address, Body and SMTP
server details (server, username, password).

Thanks

Thanks all - this group is really helpful!
 
Back
Top