以下是vb.net自动发邮件的代码,目前只支持单发,正在想办法群发
Dim mf As MailAddress = New MailAddress("sun@163.com") '表示电子邮件发件人或收件人的地址。
Dim mt As MailAddress = New MailAddress("sun@qq.com") '表示电子邮件发件人或收件人的地址。
Dim strmail As MailMessage = New MailMessage("sun@163.com", "sun@qq.com") '设置发件人与收件人
strmail.Subject = "Mthis is a test email." '邮件标题
strmail.IsBodyHtml = True '设置成为html显示
strmail.Body = "Mthis is my test email body.<br><b>this part is in bold</b>" '邮件内容
Dim strSmtpMail As SmtpClient = New SmtpClient("smtp.163.com") '调用邮箱服务器
strSmtpMail.Credentials = New NetworkCredential("name", "password") '发件人的用户登录名与密码
strSmtpMail.Send(strmail) '发送邮件
需要导入的命名空间:
Imports System.Net
Imports System.Net.Mail