Closed dmcweeney closed 4 years ago
Sorry, I'm not able to follow exactly what you're looking to do. Is is that you have some common dynamic template data that would want to apply to all personalizations?
@childish-sambino exactly 99% of the data is common, only difference is the to user name and to email is different. All the data is duplicated across numerous personalizations. If in my dynamic template I was able to determine who the target to user's name and to email address is I would not need the duplication.
In other languages we have a way to set global dynamic template data that essentially just gets copied to each personalization, but that's not the case in this C# lib. But it's not necessarily needed in order to achieve the end result.
If you have some function which returns the common dynamic template data, then you can just reference it when creating the personalization. Rough example:
private object GetCommonTemplateData()
{
return new Dictionary<string, object>
{
{ "key1", "value1" }
};
}
var personalization = new Personalization() {
Tos = new List<EmailAddress>()
{
new EmailAddress(email, name)
}
},
TemplateData = GetCommonTemplateData(),
};
@childish-sambino thats what I have working at the moment, but this duplicates the template data for each personalization - I was hoping to avoid that the keep the request body small. Is it possible?
No, the API does not support global template data.
@childish-sambino thanks for the clarification. Is there any way in the dynamic template to determine who the to user name and email is either?
No, I'm not aware of a way to do this.
Hi,
Using the v3 mail send api, with dynamic templates I am sending mails to single users with dynamic template data set. I can set the to.email and to.name in the dynamic template data I send with the request, which will give me the context info for the target recipient in the dynamic template.
However when I send to multiple users is it possible to access the context info of the target recipient from within the dynamic template - ie the to.email and to.name of the loop?
ie these values "personalizations": [ { "to": [ { "name": "A Name", "email": "user1@email.com" }, { "name": "B Name", "email": "user2@email.com" }, { "name": "C Name", "email": "user3@email.com" }],
As an workaround I was trying to include these values in the dynamic template data within personalizations but I cant figure out how to set a "global" dynamic_template_data property that contains the data that is common for all reciepients, as this is 99% common for all to users.
Is this possible?
Thanks, Donal