aspNetEmail

EmailMessage.MergedRowSent Event

A MergedRowSent event has occurred.

public event MergedRowSentEventHandler MergedRowSent;

Event Data

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

PropertyDescription
Cancel Cancels the MailMerge
Row The DataRow of data
Success Reports if the MergedRow was Successfully sent.

Example

[C#]
            void SendEmail()
            {
            	EmailMessage msg = new EmailMessage( "mail.myCompany.com");
            	msg.FromAddress = "me@myCompany.com";
            	msg.To = "##Email_Address##";
            	msg.Subject = "Order Confirmation";
            	msg.Body = "Hi ##fldFirstName##\r\n Here is your invoice and order confirmation...";
            
            	//logging for easier troubleshooting
            	msg.Logging = true;
            	msg.LogPath = "c:\\email.log";
            
            
            	//get the datatable for the mail merge
            	DataTable dt = GetDataTable();
            
            	//wire up the MergedRowSent so we can track each message sent
            	msg.MergedRowSent += new MergedRowSentEventHandler( OnRowSent );
            
            	msg.SendMailMerge( dt );
            	
            }
            
            void OnRowSent( object sender, MergedRowSentEventArgs e )
            {
            	//if we wanted to cancel the mail merge we could call
            	//e.Cancel = true
            
            	//get the email address of the row that was just sent
            	string emailAddress =e.Row[ "Email_Address" ].ToString();
            	Console.WriteLine( emailAddress );
            
            	//check to see if the merge was successfully sent
            	Console.WriteLine( e.Success );
            }
            
            
            
            
[VB.NET]
            
            Sub SendEmail()
               Dim msg As New EmailMessage("mail.myCompany.com")
               msg.FromAddress = "me@myCompany.com"
               msg.To = "##Email_Address##"
               msg.Subject = "Order Confirmation"
               msg.Body = "Hi ##fldFirstName##" + ControlChars.Cr + ControlChars.Lf + " Here is your invoice and order confirmation..."
               
               'logging for easier troubleshooting
               msg.Logging = True
               msg.LogPath = "c:\email.log"
               
               
               'get the datatable for the mail merge
               Dim dt As DataTable = GetDataTable()
               
               'wire up the MergedRowSent so we can track each message sent
               AddHandler msg.MergedRowSent, AddressOf OnRowSent
               
               msg.SendMailMerge(dt)
            End Sub 'SendEmail
             
            
            Sub OnRowSent(sender As Object, e As MergedRowSentEventArgs)
               'if we wanted to cancel the mail merge we could call
               'e.Cancel = true
               'get the email address of the row that was just sent
               Dim emailAddress As String = e.Row("Email_Address").ToString()
               Console.WriteLine(emailAddress)
               
               'check to see if the merge was successfully sent
               Console.WriteLine(e.Success)
            End Sub 'OnRowSent
            
            

See Also

EmailMessage Class | aspNetEmail Namespace