Sitecore ECM - Change order of Email Sendouts

235 Views Asked by At

I am trying to sort the order in which Sitecore ECM sends out emails - I have added a custom processor to the DispatchNewsletters pipeline , just before the sendEmails processor. But I cannot seem to change the order in which the emails are sent out. A basic example of what I am trying to do:

 public void Process(DispatchNewsletterArgs args)
    {
        IOrderedEnumerable<Contact> orderedSubscribers = args.Message.Subscribers.OrderBy(x => x.Profile.UserName.Split('_')[1]);
        List<Contact> orderedList = orderedSubscribers.ToList();
        args.Message.Subscribers.Clear();

        //Add the sorted subscriber list. 
        args.Message.Subscribers.AddRange(orderedList);
    }
}

It seems that the send out is being set from the contact or member lists and not the subscriber list. But I am unable to alter there order. Can anyone shed some light on this?

1

There are 1 best solutions below

0
On BEST ANSWER

The order of queuing emails is based on the args.Message.SubscribersNames property (not on the args.Message.Subscribers).

Still you need to remember, that emails are scheduled as asynchronous tasks, so you can not really tell if they will be processed in the same order as they are queued.

You can check the code of the Sitecore.Modules.EmailCampaign.Core.Pipelines.DispatchNewsletter.SendMessage class for more details of how the emails are processed.