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
Martin KrchnakMartin Krchnak 

Visualforce email is not sent in right language

I have a Visualforce email template which uses the Custom Labels. For all the custom labels there are translations. I determine the language of the email based on the language code on the contact:
<messaging:emailTemplate subject="{!$Label.Email_Subject}" recipientType="Contact" relatedToType="Object__c" language="{!recipient.Prefered_Language_Code__c}">
When I test the Visualforce email template in setup using the button Sent Test and Verify Merge Fields, the email shows both, in the setup and in received test email correctly, in the right language. However, when the email is triggered by the Process Builder, then it has received in English (default language). Any thought what could be wrong? Could the language depend on anything else than just the specified field Prefered_Language_Code__c on Contact?
NagendraNagendra (Salesforce Developers) 
Hi Martin,

As per Translated Template Example seems no issue with the above code as below.
<!-- This example requires that Label Workbench is enabled and that you have created the referenced labels. The example assumes that the Contact object has a custom language field that contains a valid language key. -->

<messaging:emailTemplate recipientType="Contact"
	relatedToType="Account"
	language="{!recipient.language__c}"
	subject="{!$Label.email_subject}"
	replyTo="cases@acme.nomail.com" >

	<messaging:htmlEmailBody >
	<html>
		<body>
		<p>{!$Label.email_greeting} {!recipient.name}--</p>
		<p>{!$Label.email_body}</p>
		</body>
	</html>
	</messaging:htmlEmailBody>

   </messaging:emailTemplate>
May I suggest you to please check with salesforce support team to do the needful.

Regards,
Nagendra.
 
Martin KrchnakMartin Krchnak
Hi. I tried to refer to a field on another object, and it works. Strange, though.
I have another question. If I send such Visualforce template using Send an Email button from the Contact, why the language isn't correct and also the labels are not showing. Any idea?

Thanks