I am sending the community welcome email after a portal guest user completes a custom registration form.

The welcome email is a visualforce email template, with the recipientType as User and relatedToType as Account:

<messaging:emailTemplate subject="Welcome to X" recipientType="User" relatedToType="Account">

        <p>Dear {!relatedTo.FirstName},</p>

        <p>Username: {!recipient.Username}</p>

        <a href="https://x.x.force.com/x/s/email-verification?id={!relatedTo.Id}">click here</a>


And I've tried with the relatedToType as Contact

<messaging:emailTemplate subject="Welcome to X" recipientType="User" relatedToType="Contact">

        <p>Dear {!relatedTo.FirstName},</p>

        <p>Username: {!relatedTo.Email}</p>

        <a href="https://x.x.force.com/x/s/email-verification?id={!relatedTo.AccountId}">click here</a>


The community guest login profile has Read and Create permissions on both Account and Contact objects, and User gets created successfully.

Yet none of the fields gets merged into the email.

Also, when I create the user using Apex as the Admin user, the fields do not get merged either.


  1. What am I doing wrong?
  2. How can I fix it, such that the merge field values appear?
  3. Why are two emails being sent?
  • I have a feeling the merge engine won't recognize the Account relationship since the User object is not quite like the others. You may need to write a Visualforce component and controller to retrieve the fields you need. Commented Mar 25, 2020 at 3:34
  • I believe I ran into this 2yrs ago. I went ahead with using HTML template and {!Receiving_User.FirstName},{!Receiving_User.LastName}, and {!Receiving_User.Email} in the welcome email. Give it a try. I'll provide my example and explanation for this behavior later today when I get a chance.
    – Avinash
    Commented May 22, 2020 at 20:48

2 Answers 2


Community Merge Fields are not the same as Contact merge fields and are different merge fields than normal merge fields. You need to use the merge fields allowed for Communities. Examples - try these:

{!Community.Name} {!Receiving_User.Username} {!EmailVerify_Url}

Ref: https://help.salesforce.com/articleView?id=merge_fields_communities.htm&type=5

  • I hope this helped you get merge fields for your welcome email
    – Edward
    Commented May 24, 2020 at 3:25
  • No it doesn't work with messaging:htmlEmailBody. These merge fields only work in plainTextEmailBody. Commented May 11, 2021 at 9:16

Complete Analysis and Next Action :

if the requirement is to just send welcome email, salesforce by default when community is enabled in the org, by default it will have 5 community email templates in the org. go to all templates or unified public template folder , you can see communuities:welcome email or 5 types of verification email. you can leverage this email template , by using network member fields. based on the requirement, we can add lot of merger fields which can be used for guest profile user.

enter image description here

but the requirement is only by visualforce templates, you can leverage using

{!Receiving_User.Username} {!EmailVerify_Url}

but if you are using object appended link, then please use {!.Link}

if the req is not object based, please use the {!Community.Url} . Reasom being, you dont need to change the email template in every env or in custom label(if url is in label)

please acccess network member fields in the email tempaltes all the merge fields displayed can be used in the visualforce templates..

note : please make sure in your community, welcome email is switched on email deliverabilty is ON

You must log in to answer this question.

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