1

Background

I would like to display the Community Url within a visualforce email template.

Standard templates use:

{!Community_Url}

But I cannot find an equivalent field for visualforce email templates.

Here is a simplified version of the email template:

<messaging:emailTemplate subject="Forgot Password"
    recipientType="User" relatedToType="Community">
    <messaging:htmlemailbody >

            <p>
                Dear {!recipient.Firstname },
            </p>

            <p>
            Your password has been reset for {!relatedTo.Name}. 
            </p>

            <p>
            Go to: {!$Network.NetworkUrlForUserEmails}
            </p>

    </messaging:htmlemailbody>
</messaging:emailTemplate>

Question

  1. What merge field can I use to create a link to the community?

2 Answers 2

2

I was working on a similar requirement some time back, where we had to send the reset password url for a community user.

If the Visualforce Email template you want to use, is defined under the Community Settings-->Adminstration, then using just {!$Network.NetworkUrlForUserEmails} should be good enough. If this doesn't helps you, then elaborate more on how exactly do you plan to use this template and what results do you see on using {!$Network.NetworkUrlForUserEmails}

<messaging:emailTemplate subject="forgotNew" 
    recipientType="Contact" 
    relatedToType="User"
    language="{!recipient.LanguageLocaleUser__c}"
    >
<messaging:htmlEmailBody >

<html>
<body>

    <a href = "{!$Network.NetworkUrlForUserEmails}" > Hereeee </a>

</body>
</html>



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

I am working on a requirement where I need to send a mass reset password email to our community users. In the community email template, I need to show Contact's First Name, Username from the user and NetworkUrlForUserEmails for the reset password link.

Solution -

  1. Written a small script to run from an anonymous window.

    List communityUserIds = new List{''};

    // Retrieve the list of users based on their Community User Ids List communityUsers = [SELECT Id FROM User WHERE Id IN :communityUserIds]; string emailTemplateName = 'contact_reset_password'; for (User user : communityUsers) { // Reset the password for each user using the specified email template System.resetPasswordWithEmailTemplate(user.Id, true, emailTemplateName); }

  2. We need to prepare an email template to input in our above script. I create a VF email template to utilize for reset password link from Network.NetworkUrlForUserEmails

Snippet -

<messaging:emailTemplate subject="wowwerwep" recipientType="Contact" relatedToType="Network">
        <messaging:htmlEmailBody >
            <p>Welcome {!recipient.Firstname} to  Communities</p>
            <br>A new account has been set up to 
            To complete the new account process, please click the following link to activate your account:</br>
            {!$Network.NetworkUrlForUserEmails}
            <br>URL: https://communities.epssw.com </br>
            <br>Username: {!recipient.UserName__c}</br>
            
            <br>Thank you,</br>
            <br>Software</br>
        </messaging:htmlEmailBody>
</messaging:emailTemplate>

You must log in to answer this question.

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