As the title says. If I have some logic to run that requires information about the current contact / recipient an email is being sent to, e.g. contact facets, what is the best way to get a hold of that contact profile?

  • 1
    Can you explain further about what you're trying to achieve? Are you trying to add extra information to the email from the Contact's profile?
    – Ian Graham
    Jan 30 '17 at 12:42
  • Also what version of EXM?
    – Ian Graham
    Jan 30 '17 at 12:42

EXM utilizes Sitecore's own rendering system to create each message. In doing so, the Dispatch server will make a call to the content delivery role to display the email through an HTTP call. It does so by passing in a handful of arguments, of which include both Message ID and Contact in EXM's GetBody() method.

This process then emulates as the user, meaning when Sitecore renders the components on the email, it's doing so, just like if it were drawing to a web page.

Therefore all aspects of the Sitecore Context, as well as Analytics context, exists.

That means we can retrieve the Sitecore Contact by using normal API methods.

Tracking.Current.Contact should reveal the contact that the message is being built for.

From there, you can access the Contact Facets through normal means.

If you're using a shared layout, you can use the following method to determine whether a sublayout is rendering for a normal page request or EXM is requesting a message body, use:


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.