Dim ab As Row = Tables("系统信息").Current
Dim abc As Row = Tables("人员关联表").Current
'定义邮件发送服务?端口?发件人地址?发件人授权码?发件人别名等
Dim client As New System.Net.Mail.SmtpClient(ab("单位QQ邮件网关"), ab("单位QQ邮件端口")) '或者465
client.EnableSsl = True 'SSL
client.Credentials=New System.Net.NetworkCredential(ab("单位QQ邮件"), ab("单位QQ邮件发送授权码"))
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
Dim message As New System.Net.Mail.MailMessage()
message.From=new System.Net.Mail.MailAddress(ab("单位QQ邮件"), ab("单位QQ邮件别名"))
'发送到对方邮件地址 多个收件人 对应复制多行即可
'写法一 定义邮件地址 别名
message.To.Add(new System.Net.Mail.MailAddress(abc("电子邮件"), abc("姓名")))
MessageBox.Show(abc("电子邮件"), abc("姓名"))
'写法二 定义邮件地址
'message.To.Add("15115205@qq.com")
MessageBox.Show(message.To.Add(new System.Net.Mail.MailAddress(abc("电子邮件"), abc("姓名")))
message.Bcc.Add("15285336747@139.com") '密送
'message.cc.Add("2450314695@qq.com") '抄送
'发送的邮件标题
message.Subject = "邮件测试1"
'发送邮件的编码
message.BodyEncoding = System.Text.Encoding.UTF8
'定义发送邮件的内容
Dim content As String
content &= "这是文字1" & vbcrlf
content &= "也是文字1"
message.Body = content
'定义邮件发送附件内容
Dim attachment As new System.Net.Mail.Attachment("d:\test.xls", System.Net.Mime.MediaTypeNames.Application.Octet)
message.Attachments.Add(attachment)
AddHandler client.SendCompleted, AddressOf SendCompletedCallback
Dim userState As String = "test message1"
client.SendAsync(message, userState)