How to send email with VB.NET

Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New _
Net.NetworkCredential("", "password")
SmtpServer.Port = 587
SmtpServer.Host = ""
mail = New MailMessage()
mail.From = New MailAddress("")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP mail from GMAIL"
MsgBox("mail send")
Catch ex As Exception
End Try
End Sub
End Class

Không có nhận xét nào

Được tạo bởi Blogger.

Liên hệ