اگر از ASP.net 2 استفاده میکنید ابتدا در Web.Config کدهای زیر را بعد از System.web اضافه کنید :
<system.net>
<mailSettings>
<smtp>
<network host="mail.yourhost.com"
userName="your mail" password="password" />
</smtp>
</mailSettings>
</system.net>
حال در برنامه به صورت زیر ایمیل را ارسال کنید :
'Obtain the Network Credentials from the mailSettings section
Dim credential As New System.Net.NetworkCredential( _
settings.Smtp.Network.UserName, settings.Smtp.Network.Password)
'Create the SMTP Client
Dim client As New SmtpClient()
client.Host = settings.Smtp.Network.Host
client.Credentials = credential
'Build Email Message
Dim email As New MailMessage
email.From = New MailAddress("email")
email.To.Add("email")
email.CC.Add("email")
email.Subject = "Test Email"
email.IsBodyHtml = True
email.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
email.Body = "<strong>Hello Steve!</strong>"
'Send Email
client.Send(email)