2010年6月3日 星期四

mail code

Dim newMail As New System.Net.Mail.MailMessage
Dim ToAddress(,) As String = {{"a@yahoo.com.tw", "to"}, {"a.tw@gmail.com", "to"}}
'Dim CCAddress(,) As String = {{"cc@yahoo.com.tw", "cc"}, {"cc@msa.hinet.net", "cc"}}
'Dim BccAddress(,) As String = {{"bcc@yahoo.com.tw", "bcc"}, {"bcc@msa.hinet.net", "bcc"}}

Dim AttachFile() As String = {"C:\test1.txt", "C:\test2.txt"}
Dim smtpMail As New System.Net.Mail.SmtpClient
With newMail .From = New System.Net.Mail.MailAddress(a@sig.com, "from")
'寄件者 .Body = "Hello Every Body!!"
'內文 .Subject = "測試資料!!"
'主旨 .BodyEncoding = System.Text.Encoding.GetEncoding("BIG5") '編碼方式

For i As Int32 = 0 To ToAddress.GetUpperBound(1)
'收信人 .To.Add(New System.Net.Mail.MailAddress(ToAddress(i, 0), ToAddress(i, 1)))
Next

'For i As Int32 = 0 To CCAddress.GetUpperBound(1)
'副本 '.CC.Add(New System.Net.Mail.MailAddress(CCAddress(i, 0), CCAddress(i, 1)))
'Next
'For i As Int32 = 0 To BccAddress.GetUpperBound(1) '密件副本 '.Bcc.Add(New System.Net.Mail.MailAddress(BccAddress(i, 0), BccAddress(i, 1)))
'Next
'For i As Int32 = 0 To BccAddress.GetUpperBound(1) '夾檔 For i As Int32 = 0 To ToAddress.GetUpperBound(1) '收信人 .Attachments.Add(New System.Net.Mail.Attachment(AttachFile(i))) Next .IsBodyHtml = False ' True
'是否為HTML格式 .Priority = Net.Mail.MailPriority.Normal
'優先權 End With
Try
smtpMail.Host = "smtp.sig.com.tw"
smtpMail.SendAsync(newMail, "TEST") Catch ex As Exception MsgBox(ex.InnerException)
End Try
'My.Computer.Info. MsgBox("ok mailed")

沒有留言:

張貼留言

追蹤者