VB中的电子邮件功能 [英] Email Function in VB

查看:34
本文介绍了VB中的电子邮件功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个简单的电子邮件功能,它只发送一封电子邮件(不想向我保证的任何人发送垃圾邮件!).

I need a simple email function that just sends an email (not looking to spam anyone I promise!).

任何人,任何人?使用 VB 2008

Anyone, anyone? Using VB 2008

推荐答案

使用 SmtpClient 类来执行此操作.文档页面上有一个异步发送电子邮件的示例,但这是一种基本的方法:

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)

这篇关于VB中的电子邮件功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆