I'm putting together a POC script just to test email functionality. The script works but I want to add some redundancy to it. In its current form, it sends an email using the IP address of an SMTP server (and it works as planned). What I need to do is to check that it worked and if it didn't, try again using a different SMTP server. Here is the current working code.
Code:
Imports System.Net.Mail
Module MainTest
Public Sub Main()
MsgBox("Click OK ", 0, "This is a test!")
'get the hostname
Dim strHostName As String
strHostName = System.Net.Dns.GetHostName()
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("user1@domain.com")
mail.To.Add("user2@domain.com")
'set the content
mail.Subject = "Hello"
mail.Body = "This was run on " & strHostName & "."
'send the message
Dim smtp As New SmtpClient("1.1.1.1")
smtp.Send(mail)
End Sub
End Module