You need to sign in to do that
Don't have an account?
TrueOasis
Visualforce Template - Communities Welcome Email - How to get {!Receiving_User.Username}?
Is there a way to get access to the username of the receiving community user while using a visualforce email template? I am not finding the way to get this.
With an HTML email template you simply have to use {!Receiving_User.Username}. Visualforce email templates do not like this reference.
I have tried:
Here is a simple version of my template:
<messaging:emailTemplate recipientType="Contact"
relatedToType="User"
subject="Welcome!"
replyTo="xxx@example.com">
<messaging:htmlEmailBody >
<html>
<body>
<p>Dear {!recipient.name},</p>
<p>Your username is: {!Receiving_User.Username} </p> . <----- DOES NOT WORK!
<p><a href="{!$Network.NetworkUrlForUserEmails}">Click here to register now! </a></p>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
With an HTML email template you simply have to use {!Receiving_User.Username}. Visualforce email templates do not like this reference.
I have tried:
- {!User.Username} - Wrong! That's the sending user
- {!Receiving_User.Username} - Template will not save.
- "Error: Unknown property 'core.email.template.EmailTemplateComponentController.Receiving_User'
- {!relatedTo.Username} - I can save the template but the result on receipt of the email is blank!
Here is a simple version of my template:
<messaging:emailTemplate recipientType="Contact"
relatedToType="User"
subject="Welcome!"
replyTo="xxx@example.com">
<messaging:htmlEmailBody >
<html>
<body>
<p>Dear {!recipient.name},</p>
<p>Your username is: {!Receiving_User.Username} </p> . <----- DOES NOT WORK!
<p><a href="{!$Network.NetworkUrlForUserEmails}">Click here to register now! </a></p>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
The solution: Proceed with a Custom HTML email. The only benefit missing in comparison to a VF Template is a more limited MergeField functionality (not able to do e.g. User.Contact.Name). However, based on your and my template, that does not seem to be causing an issue.
Your template would then be: I've just tested this and the email was sent properly and all merge fields were populated.