API
Version 7.x > API > Custom EmailProvider: Delete Mail form Queue View modes: 
User avatar
Member
Member
SLorenz - 2/13/2014 9:04:32 AM
   
Custom EmailProvider: Delete Mail form Queue
Hi,

I've created a custom EmailProvider that converts outgoing mails into portal messages under some circumstances. My problem is that those "mails" got stuck in the E-Mail queue because they never got sent using base.SendEMailSyncInternal().

Is there a way to remove them from the queue? I found EmailHelper.Queue.Delete(int id), but the EMailProvider doesn't provide the id.

Thanks

Stefan

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 2/14/2014 1:32:49 AM
   
RE:Custom EmailProvider: Delete Mail form Queue
Hi Stefan,

Thank you for your message.

Of course you can delete it form queue. You can do it by passing the Email ID. The ID is the column ItemID you can found in Table CMS_Email. Once you have the E-mail ID of email you want to delete you can simply call:

CMS.EmailEngine.EmailHelper.Queue.Delete(1);


Where 1 is the value EmailID.

E-mail provider does not hold this information, you should find the e-mail information in the EmailInfo object.

Kind regards,
Richard Sustek

User avatar
Member
Member
SLorenz - 2/14/2014 3:01:38 AM
   
RE:Custom EmailProvider: Delete Mail form Queue
Hi Richard,

thanks for your reply. But the question remains: How do I get the EmailID (or alternatively the EMailInfo) from a MailMessage within a custom EmailProvider?

I tried the following:

var m = new EmailMessage(message);
var mi=EmailInfoProvider.SetEmailInfo(m, EmailInfoProvider.ALL_SITES,true,false);
EmailHelper.Queue.Delete(mi.EmailID);


Getting the EMailInfo with this code doesn't work and the Mailqueue shows an error ("Datastream not readable").

Best regards

Stefan

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 2/14/2014 3:22:06 AM
   
RE:Custom EmailProvider: Delete Mail form Queue
Hi Stefan,

Thank you for your message.

This is impossible to tell. Its like you would like to get email from nothing.

You want to delete e-mail, but which e-mail? How would you tell the system which e-mail you would like to delete?

You should this code somewhere where you stop e-mails from being sent. You surely need to have some e-mail information there.

You can get the e-mail info from an EmailID, but since you only need the EmailID you dont even need to get the info. Like I said the only option is to check for e-mail ID once you "redirect" the email to system messages.

Kind regards,
Richard Sustek