Logs a custom error message to the error log as a new line. Used only in debugging, and if Logging=true
[C#]
EmailMessage msg = new EmailMessage("Mail1.MyCompany.com");
msg.Logging = true;
msg.LogPath = @"C:\temp\aspNetEmail.log";
msg.WriteLineToLog("About to set the From address.");
msg.FromAddress = "me@MyCompany.com";
msg.WriteLineToLog("About to set the To Address and Name.");
msg.AddTo( "you@YourCompany.com", "Billy Bob" );
msg.Subject = "Daily Newsletter";
msg.WriteLineToLog("About to Send the message.");
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("Mail1.MyCompany.com")
msg.Logging = True
msg.LogPath = "C:\temp\aspNetEmail.log"
msg.WriteLineToLog("About to set the From address.")
msg.FromAddress = "me@MyCompany.com"
msg.WriteLineToLog("About to set the To Address and Name.")
msg.AddTo("you@YourCompany.com", "Billy Bob")
msg.Subject = "Daily Newsletter"
msg.Body = "Here is our daily newsletter....."
msg.WriteLineToLog("About to Send the message.")
If (msg.Send()) Then
Console.WriteLine("Message Sent!")
Else
Console.WriteLine(msg.LastException().Message)
End If