开发者

Email Function in VB

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜