2016-09-17 84 views
1

發送電子郵件這是一個代碼片段用vb.net發送電子郵件:用vb.net與CC和BCC

Imports System.Net.Mail 
Public Class Form1 
    Private Sub Button1_Click(ByVal sender As System.Object, _ 
    ByVal e As System.EventArgs) Handles Button1.Click 
     Try 
      Dim SmtpServer As New SmtpClient() 
      Dim mail As New MailMessage() 
      SmtpServer.Credentials = New _ 
     Net.NetworkCredential("[email protected]", "password") 
      SmtpServer.Port = 587 
      SmtpServer.Host = "smtp.gmail.com" 
      mail = New MailMessage() 
      mail.From = New MailAddress("[email protected]") 
      mail.To.Add("TOADDRESS") 
      mail.Subject = "Test Mail" 
      mail.Body = "This is for testing SMTP mail from GMAIL" 
      SmtpServer.Send(mail) 
      MsgBox("mail send") 
     Catch ex As Exception 
      MsgBox(ex.ToString) 
     End Try 
    End Sub 
End Class 

我可以添加CC和BCC地址嗎?如果是,那麼可能的代碼是什麼?

回答

2
e_mail.CC.Add("[email protected]") 
e_mail.Bcc.Add("[email protected]") 

得到它從自己:)

+1

用於未來的建議:谷歌搜索和/或調查您正在使用的課程發佈提問前應該去。 –

+0

哦..謝謝:) –

相關問題