aspNetEmail

BeforeEmailSendEventHandler Delegate

The delegate used for event handling.

public delegate void BeforeEmailSendEventHandler(
   object sender,
   BeforeEmailSendEventArgs e
);

Example

[C#]
            static void Main(string[] args)
            {
            
            	EmailMessage msg = new EmailMessage();
            
            	//wire up the before send event, to check the mail contents
            	msg.BeforeEmailSend += new BeforeEmailSendEventHandler( OnBeforeEmailSend );
            
            	//load settings from the web.config
            	msg.LoadFromConfig();  
            
            	msg.Body = "this is my test body.";
            	msg.Send();
            
            
            	Console.WriteLine( "done" );			
            	Console.ReadLine();	
            
            }
            
            private static void OnBeforeEmailSend( object sender, BeforeEmailSendEventArgs e )
            {
            	//in here we can check the rendered email contents
            	Console.WriteLine( e.EmailContents );
            
            	//if we do not want to send the email, uncomment the following line
            	//e.Send = false;
            
            }
            
            
[Visual Basic]
            Public Overloads Sub Main()
               
               Dim msg As New EmailMessage()
               
               'wire up the before send event, to check the mail contents
               AddHandler msg.BeforeEmailSend, AddressOf OnBeforeEmailSend
               
               'load settings from the web.config
               msg.LoadFromConfig()
               
               msg.Body = "this is my test body."
               msg.Send()
               
               
               Console.WriteLine("done")
               Console.ReadLine()
            End Sub 'Main
             
            
            Private Sub OnBeforeEmailSend(sender As Object, e As BeforeEmailSendEventArgs)
               'in here we can check the rendered email contents
               Console.WriteLine(e.EmailContents)
               
            'if we do not want to send the email, uncomment the following line
            'e.Send = false;
            
            End Sub 'OnBeforeEmailSend 
            
            

Requirements

Namespace: aspNetEmail

Assembly: aspNetEmail (in aspNetEmail.dll)

See Also

aspNetEmail Namespace