日期:2014-05-18 浏览次数:20366 次
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click SendMail("fachyou@sina.com", "fachyou@126.com", Nothing, "ssss", "sssssssssssssssssssssss") End Sub Public Shared Sub SendMail(ByVal sender As String, ByVal receiver As String, ByVal cc() As String, ByVal subject As String, ByVal content As String) ' siteConfigModel = bSiteConfig.GetModel() Try Dim mail As MailMessage = New MailMessage(sender, receiver) Dim smtp As SmtpClient = New SmtpClient("smtp.sina.com") Dim nc As NetworkCredential = New NetworkCredential("fachyou@sina.com", "87654321") mail.Subject = subject mail.Body = content If Not (cc Is Nothing) Then If (cc.Length > 0) Then Dim item As String For Each item In cc mail.CC.Add(item) Next End If End If mail.IsBodyHtml = True smtp.Credentials = nc smtp.Send(mail) Catch ex As SmtpFailedRecipientException Throw New Exception(ex.Message) End Try End Sub