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);
subscriptions.Subscriptions.Add(subscription);
client.SetListSubscriptions(contact, subscriptions);
client.Submit();
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.