aspNetEmail

SmtpServerResponseEventArgs Class

An event argument used for handling SMTP server replies.

For a list of all members of this type, see SmtpServerResponseEventArgs Members.

System.Object
   EventArgs
      SmtpServerResponseEventArgs

public class SmtpServerResponseEventArgs : EventArgs

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 SmtpServerResponse event
            	msg.SmtpServerResponse += new SmtpServerResponseEventHandler( ServerResponse );
            
            	msg.Send(); 
            	
            }
            
            void ServerResponse( object sender, SmtpServerResponseEventArgs e )
            {
            	//here we can get access to the reply from the server
            
            	//what was expected
            	Console.WriteLine( e.ExpectedReplyCode );
            
            	//What was actually rec'd
            	Console.WriteLine( e.ActualReplyCode );
            	
            	//complete response
            	Console.WriteLine( e.Response );
            
            	//state of the SMTP session
            	Console.WriteLine( e.SmtpState.ToString() );
            }
            
            
            
            
[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 SmtpServerResponse event
               AddHandler msg.SmtpServerResponse, AddressOf ServerResponse
               
               msg.Send()
            End Sub 'SendEmail
             
            
            Sub ServerResponse(sender As Object, e As SmtpServerResponseEventArgs)
               'here we can get access to the reply from the server
               'what was expected
               Console.WriteLine(e.ExpectedReplyCode)
               
               'What was actually rec'd
               Console.WriteLine(e.ActualReplyCode)
               
               'complete response
               Console.WriteLine(e.Response)
               
               'state of the SMTP session
               Console.WriteLine(e.SmtpState.ToString())
            End Sub 'ServerResponse
            
            

Requirements

Namespace: aspNetEmail

Assembly: aspNetEmail (in aspNetEmail.dll)

See Also

SmtpServerResponseEventArgs Members | aspNetEmail Namespace