views:

35

answers:

1

I'm using this method in BlogEngine.net to send a number of emails to users on the site:

Utils.SendMailMessageAsync(mail);

There is already an event that is bubbled up in case of a message not being able to be sent but I don't know how to use it:

Utils.EmailFailed

Ideally I just want to count the number of messages that aren't sent and display that to the user.

A: 

I would try:

Utils.EmailFailed += new EVENT_HANDLER_OF_THE_APPROPRIATE_TYPE(METHOD_YOU_WANT_CALLED_ON_FAILURE);
Joshua Drake
I'm sorry, I've been playing around with this, but I don't get it. Can you be more specific? What would the "Appropriate Type" be?
theminesgreg
Ok, I did get this to work by doing: Utils.EmailFailed += new EventHandler<EventArgs>(Utils_EmailFailed);Then adding: //Automatic Notification Email int failedMessages = 0; void Utils_EmailFailed(object sender, EventArgs e) { failedMessages += 1; }I only wish I could get the error message to display to the user, but "e" doesn't have a message property. Is this because the writer of the event isn't bubbling it up?
theminesgreg