I have visualforce email templates for reset password & welcome email for community users. But relatedto fields are not displaying in the email template. Is it a salesforce issue?

<messaging:emailTemplate recipientType="User" relatedToType="Contact" language="{!recipient.LanguageLocaleKey}"
    replyTo="{!recipient.Email}" >

    <messaging:htmlEmailBody >

        <p>{!$Label.WelcomeMailAddressing}  {!relatedTo.Name}</p>
        <p>{!$Label.ResetMailBodyResetFirst} {!$Network.Name}. {!$Label.ResetMailBodyResetLast}</p>


This is where I am setting the email template in community. enter image description here

enter image description here

  • Can you also share the code that uses the email template? – developer__c Jun 27 '19 at 10:45
  • There is no code. I have set this email templates in community pages for welcome email & reset password. I have added a image in the question – JURY Jun 27 '19 at 10:57

The reason you are getting nothing for relatedToType="Contact" is because Contacts, Leads, and Users can't be used in relatedTo (equivalent to the WhatId)

See Apex Developer Guide outbound Apex email method setWhatId

The value must be one of the following types:

Account Asset Campaign Case Contract Opportunity Order Product Solution Custom

Fortunately, recipientType="User" provides enough information for you:

and most other fields on the User record
  • This solution is not working for community users :( – JURY Jun 28 '19 at 4:11
  • @Thirumagal.s So. recipient.email works but not recipient.firstname? – cropredy Jun 28 '19 at 4:14
  • when I try to display {!recipient.Email} in email body. It is also not coming. I clicked "Reset Password" from community user page LoggedIn as different user. Is that the issue? – JURY Jun 28 '19 at 4:20
  • I have added the screenshot in my question for "Reset Password" – JURY Jun 28 '19 at 4:22
  • How about recipient.id ? – cropredy Jun 28 '19 at 4:28

Try using firstname or lastname instead of name. Also you can depend on recipient data as well instead of relatedTo.

  • This solution is not working for community users !! – JURY Jun 28 '19 at 4:11
  • Finally its working with html email template :) . In html email template only we can use {!Receiving_User.FirstName}. From html email template we can get all the community related fields as well. Thank you! – JURY Jun 28 '19 at 6:18

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.