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">
<messaging:htmlemailbody>
<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>
</messaging:htmlemailbody>
</messaging:emailTemplate>
And I've tried with the relatedToType
as Contact
<messaging:emailTemplate subject="Welcome to X" recipientType="User" relatedToType="Contact">
<messaging:htmlemailbody>
<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>
</messaging:htmlemailbody>
</messaging:emailTemplate>
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.
Questions
- What am I doing wrong?
- How can I fix it, such that the merge field values appear?
- Why are two emails being sent?