Get email recipient data within a widget

Hi,

I have an email widget that should do some conditional content, based on the user data.

Something like “if field_xy is true…”.

How can I get the recipient data within a widget? For the preview I can check for the rc.previewRecipient and prc.record.recipient_type, which works fine.

But when sending the email, there is now recipient ID nor the prc scope.

How can I get the data of the recipient for the email that is sent?

Thanks,
Michi

You can indeed.

property name="emailSendingContextService" inject="emailSendingContextService";

// ...

var emailContext = emailSendingContextService.getContextPayload();

/*
Context struct looks like:
{
     recipientType = "..."
   , recipientId      = "..."
   , templateId      = "..."
   , template         = {}
}
*/