0

I want to send an email based on user specified language. For this we created an Visualforce Email Template with custom label:

<messaging:emailTemplate subject="15 Days of Salesforce.com Inactivity - Please Login" recipientType="User" relatedToType="User_Status__c" language="{!recipient.Email_Language__c}">
  <messaging:plainTextEmailBody >
    <apex:variable var="LastLogin15" value="{!$Label.LastLogin15}"/>
  </messaging:plainTextEmailBody>
</messaging:emailTemplate>

In the above code Email_Language__c will hold user language and LastLogin15 is a custom label which has the email content that has to be translated.

Problem: when tested using Visualforce pages this is working fine, but when I test by sending a test email it doesn't display any content. Where am I going wrong?

  • c2g___ is the Namespace for the FinancialForce Accounting package but that error message is referring to a field called c2g__c. Can you post your whole VF page because your error message does not match the code you have posted (it implies you have User_Status__c.c2g__c) – Phil Hawthorn May 22 '14 at 10:43
  • i'm not creating any vf page. It is an Email of type Visualforce.and that was the entire code i'm using to build and email template as vf – user7447 May 22 '14 at 10:46
  • in my system we didn't instal any FinancialForce Accounting Package – user7447 May 22 '14 at 10:47
  • <messaging:emailTemplate subject="15 Days of Salesforce.com Inactivity - Please Login" recipientType="User" relatedToType="User_Status__c" language="{!relatedTo.c2g__c.User__r.Email_Language__c}"> <messaging:plainTextEmailBody > Hello {!User_Status__c.User__c}, <apex:variable var="LastLogin15" value="{!$Label.LastLogin15}"/> </messaging:plainTextEmailBody> </messaging:emailTemplate> – user7447 May 22 '14 at 10:50
1

The problem is in your markup

{!relatedTo.c2g__c.User__r.Email_Language__c}

should probably be

{!relatedTo.User__r.Email_Language__c}

and

{!User_Status__c.User__c}

should be

{!relatedTo.User__c}

Maybe a copy/paste error?

|improve this answer|||||
  • when replaced received following error. Unknown property 'core.email.template.EmailTemplateComponentController.User_Status__c' – user7447 May 22 '14 at 11:03
  • Cleared errors. But in the output it only shows Hello <user id> expected is: Hello <UserNAme> the email content ,which has been stored under custom label "LastLogin15" – user7447 May 22 '14 at 11:15
  • Then you must traverse the relationship to the Username field via the User__r, rather than just reference the User__c field (which is indeed the ID). I'd suggest you do some research - you are clearly not understanding some basics here. You generally get more help on here if you've shown that you've made some effort in solving your own problem rather than just expecting people to solve new errors each time you press save. – Phil Hawthorn May 22 '14 at 11:23
0

I found solution .Here is the code which works fine

{!$Label.Email_Greeting}{!recipient.name},

{!$Label.Email_Body}

|improve this answer|||||

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.