aspNetEmail

EmailMessage.Error Event

A Error event has occurred.

public event ErrorEventHandler Error;

Event Data

The event handler receives an argument of type ErrorEventArgs containing data related to this event. The following ErrorEventArgs properties provide information specific to this event.

PropertyDescription
Exception Exception raised during the event
ThrowException If True, throws the exception.

Example

[C#]
            void SendEmail()
            {
            	EmailMessage msg = new EmailMessage( "mail.myCompany.com");
            	msg.FromAddress = "me@myCompany.com";
            	msg.To = "You@YourCompany.com";
            	msg.Subject = "test email";
            	msg.Body = "enter you body contents here...";
            
            	//logging for easier troubleshooting
            	msg.Logging = true;
            	msg.LogPath = "c:\\email.log";
            
            	//wire up the Error event
            	msg.Error += new aspNetEmail.ErrorEventHandler( OnError );
            
            	msg.Send(); 
            	
            }
            
            void OnError( object sender, aspNetEmail.ErrorEventArgs e )
            {
            	//write out the exception, but don't throw it
            	Console.Write( e.Exception );
            
            	e.ThrowException = false;
            }
            
            
            
[VB.NET]
            Sub SendEmail()
               Dim msg As New EmailMessage("mail.myCompany.com")
               msg.FromAddress = "me@myCompany.com"
               msg.To = "You@YourCompany.com"
               msg.Subject = "test email"
               msg.Body = "enter you body contents here..."
               
               'logging for easier troubleshooting
               msg.Logging = True
               msg.LogPath = "c:\email.log"
               
               'wire up the Error event
               AddHandler msg.Error, AddressOf OnError
               
               msg.Send()
            End Sub 'SendEmail
             
            
            Sub OnError(sender As Object, e As aspNetEmail.ErrorEventArgs)
               'write out the exception, but don't throw it
               Console.Write(e.Exception)
               
               e.ThrowException = False
            End Sub 'OnError
            
            

See Also

EmailMessage Class | aspNetEmail Namespace