4

How to get the recipient's language in a visualforce email?

I'm trying to use this property:

language="{!recipient.LanguageLocaleKey}"

But when the email is sent, the recipient object is the context user, and not the user who will receive the email.

Thanks in advance.

  • Where do you store the recipient's language? Is the recipient a contact, a user or a lead?. You need to pass that value to the language tag.salesforce.com/us/developer/docs/pages/Content/… – PepeFloyd May 20 '13 at 20:16
  • The recipient is an User. And the field with the language is "LanguageLocaleKey". – vanderlindo May 22 '13 at 12:27
  • Have you verified that the language is enabled in the translation workbench and that you have a translation for those values? – PepeFloyd May 22 '13 at 12:59
  • We are having a similar issue when using language="{!recipient.LanguageLocaleKey}" in VF email template , have you been able to resolve this ? I have found this known Salesforce issue which may be related : success.salesforce.com/issues_view?id=a1p30000000SdBfAAK Best Regards, Shamina – user3159 Jun 28 '13 at 11:15
1

This should work.

<messagingmessaging:emailTemplate subject="{!$Label.subject}" recipientType="Contact"
relatedToType="Account" language="{!recipient.language__c}">
<messaging:plainTextEmailBody>
{!$Label.greeting}
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
  • what is the value in {!$Label.greeting} ? i have in the same situation not sure how to do it, have a look salesforce.stackexchange.com/questions/162817/… – Nick Kahn Mar 2 '17 at 17:28
  • You have to create a custom label. Greeting is one such custom label. In the custom label, you will mention the translated version also for different languages. – sfdcFanBoy Mar 3 '17 at 2:41
0

Not sure if the above solution worked for you, but if it didn't try this: language="{!relatedTo.LanguageLocaleKey}"

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.