function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cedgcedg 

EmailTemplate not translated

Hi,

 

i've Registration object from which i want to send an email template to the Contact related to the Registration.

My email needs to be in the language of the Contact (French, Dutch, English) so i use this

 

<messaging:emailTemplate subject="Confirmation Registration" recipientType="Contact" relatedToType="Registration__c" language="{!recipient.language_email__c}">

<messaging:htmlEmailBody >
<html>
<body height="100%" width="100%">
{!$Label.Dear}<br /><br />

...

 

My $Labels are translated in the 3 needed languages.

 

The email is sent based on a change of status of the Registration.

If i use the "Send Test and Verify Merge Fields" button of the EmailTemplate with the corresponding Registration and Contact, it works fine.

However if change this status in Apex or on the Registration record itself, the mail is always sent in English. 

 

Any idea why it doesn't work otherwise ?

 

Thanks for your help

cloudmaniacloudmania

if recipient.email is null ,it will automatically be "English".Make sure that recipient.email is not null

cedgcedg

it's the case. There is a value in the email language.

But i'm not sure  of the format. I tried "FR", "fr" , "fr-fr", "fr-BE" but nothing works (except with the Send Test button)

 

Ced

cedgcedg

My mistake, i didn't check fully  :(

 

Indeed if i debug the value of the recipient.email, it is null (the recipient.Id too).

 

But i don't understand anyway why the recipient is null.

 

I've a trigger before insert to add the Contact or link an existing Contact to my registration (with an email in the Contact).

 

My Registration contains a field named Contact  (Contact__c) which is a lookup to Contact object.

 

after having inserted the Registration and its children Registrations, i change his status to "Send Confirmation Email" which fires a workflow rule with the Email Alert including this Email Template. In the config of the Email Alert, i've the Recipients = Related Contact: Contact.

 

In <messaging:emailTemplate subject="Confirmation Registration" recipientType="Contact" relatedToType="Registration__c" language="{!recipient.language_email__c}">

 

how does it make the link between the Recipients of the config and the {!recipient}. Am i missing a parameter or a config somewhere ?

 

Thanks

 

 

 

 

cedgcedg

Moreover if the recipient.email is null, how is it possible that i receive the email ?

 

Ced

cedgcedg

One workaround is to create on Registration object a formula to Contact.language_email__c and to use it in language parameter of the emailTemplate

 

<messaging:emailTemplate subject="Confirmation Registration" recipientType="Contact" relatedToType="Registration__c" language="{!relatedTo.language_email__c}">

 

Not very clean but it's working.

 

If somebody has a clean solution, please share it :-)

 

Thanks