aspNetEmail

EmailMessage.To Property

Allows you to easily set the EmailMessage.To property of an email without having to use the EmailMessge.AddTo() method.

public string To {get; set;}

Remarks

For Example:

EmailMessge.To = "me@myCompany.com" Using the To property, you cannot set the 'Name' of the recipient, only the email address. If you want to use a name, then use the EmailMessage.AddTo( EmailAddress, Name) overloaded method.

You can also use commas (,) or semi-colons if you want to use multiple email addresses with the EmailMessage.To property.

For example:

EmailMesage.To = "me@myCompany.com;you@yourCompany.com;him@hisCompany.com"

Example

[C#]
		EmailMessage msg = new EmailMessage();
		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.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