开发者

Email Function in VB

开发者 https://www.devze.com 2022-12-19 03:26 出处:网络
I need a simple email function that just sends an email (not look开发者_StackOverflow中文版ing to spam anyone I promise!).

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号