Imports System.Net.Mail Shared Function sendMail(ByVal fromName As String, ByVal from As String, ByVal rcpt As String, ByVal subject As String, ByVal body As String, ByVal isBodyHTML As Boolean, ByVal BCCRcpt As String) As Boolean 'Returns True if send ok, False if errors Dim pEmailMessage As New MailMessage Dim pSmtpClient As New SmtpClient Dim pSmtpServer As String Dim pSmtpUser As String Dim pSmtpPass As String Dim pMailServerUser As String pSmtpServer = "chnexc001.gavsin.com" pMailServerUser = String.Empty pSmtpUser = "root" pSmtpPass = "draddots" pEmailMessage.From = New System.Net.Mail.MailAddress(from, fromName) If rcpt <> String.Empty Then pEmailMessage.To.Add(rcpt) End If If BCCRcpt <> String.Empty Then pEmailMessage.Bcc.Add(BCCRcpt) End If pEmailMessage.Subject = subject pEmailMessage.Body = body pEmailMessage.IsBodyHtml = isBodyHTML pEmailMessage.Priority = System.Net.Mail.MailPriority.Normal pSmtpClient.Host = pSmtpServer If Trim(pSmtpUser) <> "" Then pSmtpClient.Credentials = New System.Net.NetworkCredential(pSmtpUser, pSmtpPass) End If Try pEmailMessage.IsBodyHtml = True pSmtpClient.Send(pEmailMessage) sendMail = True Catch ex As Exception sendMail = False End Try End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)