1

We are trying to use EXM for the subscription, creating a page where user will enter email, click on button and they will get subscription email.

Trying to use EXM client API for this UpdateListSubscription()

Code:

IClientApiService _clientApiService;
      
public TestController(IClientApiService clientApiService)
{
    _clientApiService = clientApiService;
}

public void UpdateListSubscription()
{
            var subscribeOptions = new UpdateListSubscriptionMessage();
            var contact = new Sitecore.XConnect.Contact(
                       new Sitecore.XConnect.ContactIdentifier("ListManager", "test@gmail.com", Sitecore.XConnect.ContactIdentifierType.Known)
                       );
            subscribeOptions.ListSubscribeOperation = ListSubscribeOperation.Subscribe;
            subscribeOptions.MessageId = Guid.NewGuid();
            subscribeOptions.RequireSubscriptionConfirmation = true;
            subscribeOptions.ContactIdentifier= contact.Identifiers.FirstOrDefault(); 
            _clientApiService.UpdateListSubscription(subscribeOptions);
 }

For the Subscription using ListSubscribeOperation.Subscribe. However, it is not sending any email after running all the code and not throwing any errors.

Here we are using ContactIdentifier and what is the use of it here and how can we use this with above code.

Can someone let me know is this the right approach for the user subscription?

1

You can use this example code to send email using client API:

public void SendAutomatedExample(Guid messageId, ContactIdentifier identifier)
{
    var messageOpitons = new AutomatedMessage();

    messageOpitons.MessageId = messageId;
    messageOpitons.ContactIdentifier = identifier;
    messageOpitons.TargetLanguage = "en";

    //Send Message
    ClientApiService.SendAutomatedMessage(messageOpitons);
}

}

2
  • What is the content of the email ? what is messageId and identifier here ? – User7864 Mar 25 at 12:53
  • MessageId is the guid of your custom message and identifier would be the contactidentifier which you are getting in your code – Cristi Vulturar Mar 25 at 13:59

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.