Jump to content

cbox


Recommended Posts

Posted
	Public Shared Sub SendMessage(ByVal subject As String, ByVal messageBody As String, _
   ByVal fromAddress As String, ByVal toAddress As String, ByVal ccAddress As String)

	Dim message As New MailMessage()
	Dim client As New SmtpClient()

	'Set the sender's address
	message.From = New MailAddress(fromAddress)

	'Allow multiple "To" addresses to be separated by a semi-colon
	If (toAddress.Trim.Length > 0) Then
		For Each addr As String In toAddress.Split(";"c)
			message.To.Add(New MailAddress(addr))
		Next
	End If

	'Allow multiple "Cc" addresses to be separated by a semi-colon
	If (ccAddress.Trim.Length > 0) Then
		For Each addr As String In ccAddress.Split(";"c)
			message.CC.Add(New MailAddress(addr))
		Next
	End If

	'Set the subject and message body text
	message.Subject = subject
	message.Body = messageBody

	'TODO: *** Modify for your SMTP server ***
	'Set the SMTP server to be used to send the message
	client.Host = "Host" 'Your SMTP Server goes here
	client.Credentials = New System.Net.NetworkCredential( User, Pass) 'login info for the SMTP
	'client.Port = ""   'if needed remove the ' from before it
	client.EnableSsl = False 'SSl for SMTP
	'Send the e-mail message
	client.Send(message)

End Sub

  • 2 weeks later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...