EventArgs used for checking the EmailMessage before it is sent.
For a list of all members of this type, see BeforeEmailSendEventArgs Members.
System.Object
EventArgs
BeforeEmailSendEventArgs
[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
Namespace: aspNetEmail
Assembly: aspNetEmail (in aspNetEmail.dll)