2

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}"
    subject="{!$Label.ResetMailSubject}"
    replyTo="{!recipient.Email}" >

    <messaging:htmlEmailBody >

        <p>{!$Label.WelcomeMailAddressing}  {!relatedTo.Name}</p>
        <p>{!$Label.ResetMailBody}</p>
        <p>{!$Label.ResetMailBodyResetFirst} {!$Network.Name}. {!$Label.ResetMailBodyResetLast}</p>
        <p>{!$Network.NetworkUrlForUserEmails}</p>
        <p>{!$Label.ResetMailBodyWarning}</p>
        <br/>
        <br/>
        <p>{!$Label.WelcomeMailClosing}</p>


    </messaging:htmlEmailBody>
</messaging:emailTemplate>

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

enter image description here

2
  • Can you also share the code that uses the email template? Jun 27, 2019 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, 2019 at 10:57

2 Answers 2

2

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:

{!recipient.FirstName}
{!recipient.LastName}
and most other fields on the User record
12
  • This solution is not working for community users :(
    – JURY
    Jun 28, 2019 at 4:11
  • @Thirumagal.s So. recipient.email works but not recipient.firstname?
    – cropredy
    Jun 28, 2019 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, 2019 at 4:20
  • I have added the screenshot in my question for "Reset Password"
    – JURY
    Jun 28, 2019 at 4:22
  • How about recipient.id ?
    – cropredy
    Jun 28, 2019 at 4:28
0

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

2
  • This solution is not working for community users !!
    – JURY
    Jun 28, 2019 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, 2019 at 6:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .