aspNetEmail

EmailMessage.ValidateAddress Property

Validates addresses before they are added to the To, Bcc, or Cc fields with the regular expression pattern set by ValidateRegEx.

public bool ValidateAddress {get; set;}

Remarks

The default is true; you may want to turn off, if your mail server allows you to mail someone by only their name, for example: JSmith, or if your mail server will resolve the domains for you, for example JSmith@myCompany (notice the lack of a top level domain such as .com or .net).

Example

[C#]
		EmailMessage msg = new EmailMessage();
		msg.ValidateAddress = false;
		msg.Server = "Mail1.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.ValidateAddress = False
		msg.Server = "Mail1.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