aspNetEmail

EmailMessage.Server Property

The MailServer to relay through.

public string Server {get; set;}

Remarks

For example: obj.MailServer = "mail1.mycompany.com" The MailServer property also has the ability to use redundant mail servers. If the first server is down when the object attempts to connect, will attempt to connect to the next server in the list. To specify redundant servers, separate them by semicolons ";" or commas ",". For example: obj.Server = "mail1.mycompany.com;mail2.mycompany.com;mail3.mycompany.com". If mail1.mycompany.com is down, when the initial connection is made, aspNetEmail will attempt to connect to mail2.mycompany.com. If the connection to mail2.mycompany.com fails, aspNetEmail will attempt to connect to mail3.mycompany.com. If mail3.mycompany.com fails, then the component shuts down and does not send any email. Redundant servers are only tested during the initial connection of a mail session. Once a valid connection is made, aspNetEmail will use that mail server for the rest of it's session. If the session terminates unexpectedly, aspNetEmail will throw an exception.

Example

[C#]
		EmailMessage msg = new EmailMessage();
		msg.Server = "Mail1.MyCompany.com;Mail2.MyCompany.com;Mail3.MyCompany.com";
		msg.FromAddress = "me@MyCompany.com";
		msg.To = "you@YourCompany.com";
		msg.Subject = "Daily Newsletter";
		msg.Body = "Here is our daily newsletter.....";
		if ( msg.Send() )
		{
			Console.WriteLine( "Message Sent!");
		}
		else
		{
			Console.WriteLine( msg.LastException().Message );
		}
		
[Visual Basic]
		Dim msg As New EmailMessage()
		msg.Server = "Mail1.MyCompany.com;Mail2.MyCompany.com;Mail3.MyCompany.com"
		msg.FromAddress = "me@MyCompany.com"
		msg.To = "you@YourCompany.com"
		msg.Subject = "Daily Newsletter"
		msg.Body = "Here is our daily newsletter....."
		If (msg.Send()) Then
		    Console.WriteLine("Message Sent!")
		Else
		    Console.WriteLine(msg.LastException().Message)
		End If
		

See Also

EmailMessage Class | aspNetEmail Namespace