Imports System.Web.Mail.SmtpMail
Imports System.Data
Imports System.Data.SqlClient
Function SendEmail(ByVal strTo As String, ByVal strFrom As String, ByVal strBody As String, ByVal strSubject As String, Optional ByVal strCC As String = "") As Boolean
Dim email As New System.Web.Mail.MailMessage()
email.To = strTo
email.Cc = strCC
email.From = strFrom
email.Body = strBody
email.Subject = strSubject
email.BodyFormat = Web.Mail.MailFormat.Text
Try
System.Web.Mail.SmtpMail.SmtpServer = "primaryserver.com"
System.Web.Mail.SmtpMail.Send(email)
Catch e As Exception
Debug.WriteLine(e)
email.Body = strBody & vbCrLf & vbCrLf & "MAIN SMTP SERVER ERROR: " & vbCrLf & e.ToString
System.Web.Mail.SmtpMail.SmtpServer = "secondary server.com"
System.Web.Mail.SmtpMail.Send(email)
End Try
Return True
End Function
Welcome to my programming blog. This Blog contains my research and notes pertaining to programming. You are free to use any information on this site however you must make a comment on the blog, and put credit in your code that you obtained it from here. You can contact me directly at rob @at@ robsprogrammingjunk.com.
Wednesday, March 15, 2006
VB.NET: SMTP Mail
Easy SMTP function in VB.NET
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment