Kentico 13 MVC Custom Email Provider > Remove Email from Queue

Alexandre Zuppo asked on July 28, 2023 23:50

I´ve followed this guide to implement a Custom Send Email class, my final class is pretty similar to the sample class in the documentation page. https://docs.xperience.io/custom-development/customizing-providers/custom-email-provider-example

However (due to business requirements) now I need to send emails using a third party class, not by calling base.SendEmailInternal() anymore.

OK, I am able to implement that, the emails are been sent properly and the email recipients receive the email. Those steps are working fine, but the email objects are keeping in "Email Queue" tab with Waiting/Sending status.

I´d like to know if there is a way to change the status of those email objects so that they could appear in the "Sent emails" tab? I mean, there´s a way to properly manipulate the status of the email objects in the queue? Calling some other static method, implementing some interface, or anything else?

I understand that if I sent the emails using the base.SendEmailInternal(), internally Kentico will send the email and change their status to 3 (sent) in database so that email object will appear in the "Sent emails" instead of "Email Queue" tab. But I am not using this method.


In the overrided method SendEmailAsyncInternal() of my custom class, I received a EmailToken object that contains many information including a instance of the SMTPServer and EmailInfo, but those objects are not public and I am unable to access it. * One of my ideas was change the property EmailStatus to 3 in the EmailToken them pass it to another Kentico method so (internally) Kentico could properly do the final steps of the job (change the status of the email object in database).

I am using Kentico 13 MVC, v13.0.118.

Thanks in advance!

Recent Answers


Brenden Kehren answered on July 29, 2023 00:34

Once you receive confirmation from your 3rd party process that an individual email has been sent, update that email object and set the proper status and date. The email queue and sent email lists are filtered out by that status ID on the email object.

2 votesVote for this answer Mark as a Correct answer

Alexandre Zuppo answered on July 29, 2023 00:51

Brenden, thanks for quick answer! You mean update the email object directly by EmailInfo / EmailInfoProvider classes, right?

Additionally, there´s a way to parse the EmailToken object? I am asking it because inside the overrided methods of EmailProvider, I just have access to a System.Net.Mail.MailMessage object, without EmailInfoID or EmailGUID.

Thanks you again!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.