We are using Sitecore 9.1 (Update-1). We have a third-party email management system. One of our requirements is if anyone unsubscribes from the third-party email system, we have to consider their email in our Sitecore EXM. To fulfill that we are creating a new contact, new contact facet, and adding the contact in our Common Global Opt-out list and it is successfully adding to the list.

But while we are sending an email to the same user it is not filtering the contact. The contact is in the global opt-out list but they are getting the email as well.

To add to the list we tried the following codes

var subscriptionService =  (ISubscriptionService)ServiceLocator.ServiceProvider.GetService(typeof(ISubscriptionService));
subscriptionService.Subscribe(listId, Guid.Parse(existingContact.Id.ToString()));

We tried the following code as well, here XConnectClient client, Contact existingContact

                ContactListSubscription subscription = new ContactListSubscription(added, isActive, listId);

                client.SetListSubscriptions(contact, subscriptions);

Both are adding to the Common Global Opt-out list but not getting filtered out.

Please help if anyone works on a similar issue, thanks.

2 Answers 2


ISubscriptionManager contains methods for subscription/unsubscription

 public interface ISubscriptionManager
    bool Subscribe(
      ContactIdentifier contactIdentifier,
      Guid messageId,
      bool subscriptionConfirmation);

    bool Unsubscribe(ContactIdentifier contactIdentifier, Guid messageId);

    bool UnsubscribeFromAll(ContactIdentifier contactIdentifier, Guid managerRootId);

    bool UnsubscribeFromAll(Contact contact, ManagerRoot managerRoot);

    bool ConfirmSubscription(string cid);

    string GetConfirmationKey(
      Guid recipientListId,
      ContactIdentifier contactIdentifier,
      ManagerRoot managerRoot);

    bool ConfirmSubscription(ShortID id);

    bool AddToGlobalOptOutList(ContactIdentifier contactIdentifier, ManagerRoot managerRoot);

    bool RemoveContactFromList(ContactIdentifier contactIdentifier, Guid listId);

    bool RemoveContactFromList(Contact contact, Guid listId);

    bool AddContactToList(ContactIdentifier contactIdentifier, Guid listId);

    Guid GetSubscriptionListFromMessage(MessageItem messageItem);

Your code will look in this way:

(Factory.CreateObject("exm/subscriptionManager", true) as ISubscriptionManager).AddToGlobalOptOutList(new ContactIdentifier("ListManager", "youremailaddress", ContactIdentifierType.Known), yourmanagerroot);

To get ManagerRoot you can use the public method:

 public static ManagerRoot FromItem(Item rootItem) => ManagerRoot.IsManagerRoot(rootItem) ? new ManagerRoot(rootItem) : (ManagerRoot) null; 

from the class Sitecore.Modules.EmailCampaign.ManagerRoot

var subscribeOptions = new UpdateListSubscriptionMessage();
subscribeOptions.ListSubscribeOperation = ListSubscribeOperation.UnsubscribeFromAll;

subscribeOptions.ContactIdentifier = new ContactIdentifier(source, identifier, ContactIdentifierType.Known);
subscribeOptions.ManagerRootId = managerRoot;

var clientApiService = ServiceLocator.ServiceProvider.GetService<IClientApiService>();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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