1

I'm trying to send a welcome email with more customised content to some users we're creating automatically. I've disabled the send email functionality when a user is created, but now I'm stuck when I'm writing the VF template, with the value from {!$Network.NetworkUrlForUserEmails} not being generated.

Here's the template:

<messaging:emailTemplate subject="You've been added as a contact" recipientType="User" relatedToType="Network" >
<messaging:plainTextEmailBody >
Hi {!recipient.Name}
You've been added as a secondary contact!
Log in here:{!$Network.NetworkUrlForUserEmails}

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

I see that you're supposed to use {!$Network.NetworkUrlForUserEmails} for the initial URL (As seen here), but that's coming through blank. {!recipient.Name} works.

I also read that the $network fields are only available for community email templates, but I don't know what the difference is between those and normal email templates. I can see community tagged ones like the welcome email, but I'm not sure how to create "community" VF templates from scratch.

I'm sending this email via apex so that I can invoke it from Process Builder.

4
  • Did you get answer to this question??
    – SF Learner
    Apr 4, 2019 at 21:35
  • No, never figured it out, I'm not sure if it's possible. Apr 5, 2019 at 22:45
  • 1
    To answer some of your questions, Community VF templates are the templates that are used on the Communities->Workspace->Administration->Email page. They have the communities context and that is the reason they are able to fetch these values for the community. This does not seem to be possible to be retrieved in any other programmatical way from my research so far.
    – SF Learner
    Apr 7, 2019 at 21:51
  • Yeah, that's where I ended up too. Thanks for coming back. Apr 8, 2019 at 23:18

2 Answers 2

0

I was facing a similar issue where I was trying to send a community welcome email to a new users with the sendWelcomeEmail=false in the site. We needed this because some users have SSO and some do not.

Trying to the send the a vf template with the {!$Network.NetworkUrlForUserEmails} merge field using Messaging.SingleEmailMessage() just resulted in the link being null.

I found that if you call system.resetPasswordWithEmailTemplate() and specify the standard Community Welcome Email Template this works.

My implementation:

system.resetPasswordWithEmailTemplate(u.Id, true, 'CommunityWelcomeEmailTemplate');
-1

use <messaging:htmlEmailBody> instead of <messaging:plainTextEmailBody>

2
  • I've downvoted because it's not clear why this would have any effect. The explanation is as important as the answer.
    – Derek F
    Nov 18, 2022 at 12:31
  • @DerekF, have you tried? If this solves the issue and is helpful, some gratitude is appropriate, even without explanation. Yes, better explain! But if not (e.g. because one doesn't have a clue why), - I still want to encourage people to answer. Nov 18, 2022 at 15:48

You must log in to answer this question.

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