Josh streit
Josh streit

Reputation: 207

Email Function in VB

I need a simple email function that just sends an email (not looking to spam anyone I promise!).

Anyone, anyone? Using VB 2008

Upvotes: 2

Views: 1132

Answers (1)

womp
womp

Reputation: 116977

Use the SmtpClient class to do this. There's an example of sending an email asynchronously on the documentation page, but here's a basic way of doing it:

Dim client As New SmtpClient("mail.myisp.com")

Dim fromAddr As New MailAddress("[email protected]")
Dim toAddr As New MailAddress("[email protected]")
Dim message As New MailMessage(fromAddr, toAddr)
message.Body = "This is a test e-mail message sent by an application. "
message.Subject = "test message 1"

client.Send(message)

Upvotes: 7

Related Questions