' 兩個收件人:GetMail1@gmail.com和GetMail2@gmail.com
Dim To_Address As String = "GetMail1@gmail.com;GetMail2@gmail.com"
' 設定SMTPserver
Dim SMTP_Server As New Mail.SmtpClient("msa.hinet.net")
Dim Mailmsg As New System.Net.Mail.MailMessage
Dim MailBodyHtml As String
' 設定一個信件的附檔
Dim mail_attachment As New System.Net.Mail.Attachment("Z:\Picutre\nic.jpg")
Mailmsg.IsBodyHtml = True ' 為html內容格式
' 此信的寄件人
Mailmsg.From = New Net.Mail.MailAddress("Send@msa.hinet.net", "寄件人")
Mailmsg.Subject = "主旨"
MailBodyHtml = "Mail Message First"
MailBodyHtml &= "Mail Message Second"
Mailmsg.Body = MailBodyHtml
' 把附檔加入到Mail
Mailmsg.Attachments.Add(mail_attachment)
' 將字串裡的;分為多個收件人
For Each MA As String In To_Address.Split(";")
Mailmsg.To.Add(New Net.Mail.MailAddress(MA, "收件人"))
Next
' 密件副本收件人
Mailmsg.Bcc.Add(New Net.Mail.MailAddress("GetMail3@gmail.com", "密件副本"))
Mailmsg.Priority = Net.Mail.MailPriority.High
' Smtp(Server) 的帳號與密碼
SMTP_Server.Credentials = New System.Net.NetworkCredential("ID", "PW")
SMTP_Server.Send(Mailmsg)
沒有留言:
張貼留言