I need a simple email function that just sends an email (not look开发者_StackOverflow中文版ing to spam anyone I promise!).
Anyone, anyone? Using VB 2008
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("jane@contoso.com")
Dim toAddr As New MailAddress("ben@contoso.com")
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)
精彩评论