bulkAgent_BulkSendCompleted event and logging

Hi,



In the method below I would like to log some information (TotalProcessed, TotalSent, TotalFailed), but all of these variable are always empty.



void bulkAgent_BulkSendCompleted(object sender, EventArgs e)

{

if (_bulkAgent != null)

{

_logger.Info(“Bulk Email Summary”);

_logger.InfoFormat("Number of emails processed: ", _bulkAgent.TotalProcessed);

_logger.InfoFormat("Number of emails sent: ", _bulkAgent.TotalSent);

_logger.InfoFormat("Number of emails with error: ", _bulkAgent.TotalFailed);





It outputs :

Bulk Email Summary

Number of emails processed:

Number of emails sent:

Number of emails with error:

Hi Dominique,

Thank you for writing to Aspose support team.

I have tested this scenario with the latest version of Aspose.Email for .NET 4.3.0 and all the fields contain correct information. The same number of emails are received on the other end. Could you please give it a try using this latest version and let us know your feedback? If the issue still persists, please provide us with your sample console application for reproducing this issue at our end. We’ll look into it to assist you further.

Sample Code:

MailMessage msg;
SmtpClient client = new SmtpClient("smtp.gmail.com","username","password");
client.SecurityOptions = SecurityOptions.SSLExplicit;
SmtpClientBulkSendAgent agent = new SmtpClientBulkSendAgent(client);
for (int i = 0; i < 1000; i++)
{
    msg = new MailMessage("sender@gmail.com", "receiver@gmail.com");
    msg.Subject = "bulksend No." + i;
    msg.Body = "bulksend testing";
    //msg.Attachments.Add(new Attachment("Test.001.png"));
    agent.AddMessage(msg);
}
agent.Start();
while (agent.TotalProcessed < 200)
{
    Console.WriteLine(DateTime.Now.ToLongTimeString()
        + " total sent:" + agent.TotalSent
        + " total quequed:" + agent.TotalQueued
        + " total processed:" + agent.TotalProcessed);
    System.Threading.Thread.Sleep(10);
}

I’ve updated Aspose.Email to version 4.3.0 (last one), and I observe the same results.



In your example you don’t use the bulkAgent.BulkSendCompleted event :



_bulkAgent.BulkSendCompleted += new EventHandler(bulkAgent_BulkSendCompleted);



void bulkAgent_BulkSendCompleted(object sender, EventArgs e)

{

if (_bulkAgent != null)

{

_logger.Info(“Bulk Email Summary”);

_logger.InfoFormat("Number of emails processed: ", _bulkAgent.TotalProcessed);

_logger.InfoFormat("Number of emails sent: ", _bulkAgent.TotalSent);

_logger.InfoFormat("Number of emails with error: ", _bulkAgent.TotalFailed);

}

}



I log the message into this event.

Sorry forgot my problem !
it lacks the {0} :stuck_out_tongue:

Hi Dominique,

We are glad to know that your issue is resolved. Please feel free to write us back if you have any other query related to Aspose.Email.