5

Sitecore doc Recipient repositories claims "The Email Experience Manager can use various sources of recipients to send email campaigns, including both the sources provided by Sitecore and your own sources."

Apparently, to do this, you would need to (1) create a custom recipient repository, other than the default XdbRecipientRepository, and then (2) get EXM to use your custom repository when sending emails. But I can find no clue how to do either of these things. Does anyone have links or tips to how to do this?

Our use case is: We need to send mailings to a couple of "internal" lists (all employees & all students). It would be much easier to just create recipient lists "directly", rather than having to create and manage xDB contacts for these mailings. It should also be much more performant, because the xDB contacts API runs very slowly.

This is Sitecore 8.2, EXM 3.5.

Thanks!

Edit: Multiple answerers have suggested that we use List Manager's "Import CSV" feature rather than do what I'm asking to do in my question, so I'll explain why we're not doing that:

  1. "Import CSV" is an interactive manual feature of List Manager. We need to synchronize these lists automatically (daily), not just import them once.

  2. We need to add recipients to these lists ongoing, not just import the lists once.

  3. We need to modify existing recipient's properties when the source properties change, not just import new recipients.

  4. We need to remove recipients when they're removed from the source lists, not just import new recipients.

  • Note: Mark Cassidy changed the title of my question, so it no longer indicates the key point of my question. The key point is: I want to create recipient lists where the recipients are not xDB contacts, as the Sitecore documentation page I linked to claims we can. How do I do this? – Conrad Albrecht Sep 12 '18 at 23:41
0

I would not recommend the approach you're asking for help with. I'll address your comments and questions later, but first address what you're trying to do.

Apparently, to do this, you would need to (1) create a custom recipient repository, other than the default XdbRecipientRepository, and then (2) get EXM to use your custom repository when sending emails. But I can find no clue how to do either of these things. Does anyone have links or tips to how to do this?

As explained in the article, you will need to patch the recipientRepository section in Sitecore.EmailExperience.Core.config. You can either replace the default XdbRecipientRepository with your own implementation of Sitecore.Modules.EmailCampaign.Recipients.RecipientRepository, or just add your own.

However, I strongly recommend you do not go down this path.

  1. The RecipientRepository is removed in later versions of EXM, so you will not have an upgrade path
  2. In addition to implementing a custom RecipientRepository, you will also have to implement custom logic for handling unsubscribes and several other areas.

Now, as far your comments and questions.

It would be much easier to just create recipient lists "directly", rather than having to create and manage xDB contacts for these mailings.

On paper, this may be true, but then your requirements change, maybe you'll need to work with contact facets or use the contact data for personalisation - either on the website or in an email campaign. Neither of which you'll be able to do. Additionally, if you don't use xDB, you will have to write your own code for creating and managing contacts, which brings me on to your second point:

It should also be much more performant, because the xDB contacts API runs very slowly.

That's a dangerous assumption to make. Who's to say your external list, or managing of contacts will not prove to be a bottleneck?

"Import CSV" is an interactive manual feature of List Manager. We need to synchronize these lists automatically (daily), not just import them once.

We need to add recipients to these lists ongoing, not just import the lists once.

We need to modify existing recipient's properties when the source properties change, not just import new recipients.

We need to remove recipients when they're removed from the source lists, not just import new recipients.

This can all be done in xDB. A contact has a unique identifier, which you can use to synchronize changes from your external list into xDB, allowing you to add, modify and remove contacts as necessary.

xDB is a major and integral part of Sitecore. If you're using Sitecore and want to work with contacts, you should have an extremely good reason for not using what's already "in the box". What you're aiming to do is "run of the mill", and I promise you'll regret going down the custom recipient repository route.

| improve this answer | |
  • Thanks for responding. These comments don't let me respond in detail, but if RecipientRepository is removed in later versions, that's enough reason to not use it. I'll continue while space allows: "The article" lets you turn your own custom Recipient Identifiers into Recipient objects, but it doesn't give you a way to create/pass lists of these custom IDs to an email campaign, a critical missing piece. I've seen the difficulty of the xDB API, and its performance (~1 sec / contact edit), and I'm capable of judgment calls on requirements, API difficulty, and performance, thank you. – Conrad Albrecht Sep 21 '18 at 17:45
2

you can create Contact Lists from a CSV-File that's the most easiest way.

Furthermore you can create your lists programmatically, we also do that because a customer of us wants to send newsletters from a third party CRM-System, so we offered an API to catch the contacts and the newsletter id, build the contactlist and include it in the newsletter.

Looks like this:

       var newsletterRecipientListName = string.Format("{0}_{1}", newsletter.Settings.NewsletterItemId, DateTime.Now.Ticks);
       var filteredContacts = newsletter.Contacts.DistinctBy(x => x.Email.ToLowerInvariant()).ToList();
       var listId = _listManagementService.CreateList(newsletterRecipientListName, filteredContacts, messageItem.ManagerRoot.InnerItem.ID.ToString());
       messageItem.RecipientManager.AddIncludedRecipientListId(new ID(listId));

The CreateList Method looks like this:

    public string CreateList(string listName, IEnumerable<Analytics.Contacts.Models.Contact> contacts, string managerRootId)
    {
        var listManager = Factory.CreateObject("contactListManager", false) as ContactListManager;
        var list = new ContactList(listName);
        if (listManager == null)
        {
            return string.Empty;
        }
        using (new SecurityDisabler())
        {
            listManager.Create(list);
            var contactDatas = GetContactDatas(contacts);

            AssignContactsToList(contactDatas, list.Id, managerRootId);
        }

        return list.Id;
    }

We have created our own Contact model because the contacts are enriched with much more facets than the default ones. We then Subscribe them to the contact list:

    protected void AssignContactsToList(IEnumerable<ContactData> contacts, string contactListId, string managerRootId)
    {
        foreach (var contactData in contacts)
        {
            var recipientId = new Sitecore.Modules.EmailCampaign.Xdb.XdbContactId(contactData.ContactId);

            Sitecore.Modules.EmailCampaign.ClientApi.UpdateSubscriptions(recipientId, new[] { contactListId }, new string[] { }, managerRootId, false);
        }
    }

Best regards Dirk

| improve this answer | |
  • Thanks, but (1) re the CSV Import feature: See my edit to the OP. (2) Re your code sample: I already have code to add xDB contacts to our mailing lists; I'm trying to avoid having to create xDB contacts at all for these mailings. – Conrad Albrecht Sep 12 '18 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.