vb.net发送电子邮件

Beg*_*ner 10 vb.net email

我想知道如何从vb应用程序中发送电子邮件?任何人都可以协助从哪里开始?

Mor*_*son 13

在System.Net.Mail命名空间中使用SmtpClient类

例.

'create the mail message
Dim mail As New MailMessage()

'set the addresses
mail.From = New MailAddress("xx@xx")
mail.[To].Add("xx@xx")

'set the content
mail.Subject = "This is an email"
mail.Body = "this is a sample body"

'set the server
Dim smtp As New SmtpClient("localhost")

'send the message
Try
    smtp.Send(mail)
    Response.Write("Your Email has been sent sucessfully - Thank You")
Catch exc As Exception
    Response.Write("Send failure: " & exc.ToString())
End Try
Run Code Online (Sandbox Code Playgroud)