Activity › Forums › Salesforce® Discussions › How to send Community Welcome Email to a User through Salesforce Apex?
Tagged: Community, Community Cloud, Community User, Community Welcome Email, Salesforce Apex, Salesforce Apex Class, Salesforce Apex Code, Salesforce Apex Controller, Salesforce Community
-
How to send Community Welcome Email to a User through Salesforce Apex?
Posted by Neha on March 23, 2018 at 5:45 AMHow to send Community Welcome Email to user through Apex ?
Neha replied 8 years, 1 month ago 4 Members · 11 Replies -
11 Replies
-
My correct question is “How to send Community Welcome email to user through Apex ?”
- [adinserter block='9']
-
Hi Neha,
You can try this using session id and create a url for the user and send back to the user to login https://<endpoint host>/secur/frontdoor.jsp?sid=<session id>”
OR
This particular feature is not very admin friendly (as you found out the hard way:). We chose to uncheck the “Send welcome email” box under Communities > Administration > Emails. We then created a workflow rule on the User object to send out the welcome email to new community users. The workflow rule fires on record creation only as has a criteria for “Profile EQUALS ‘Your Community Profile Name(s)'”.
Hope this helps you.
-
You can also achive this by writting trigger on User sObject to shoot an email as per the example provided below. It can be achieve using workflow rule also but I am not sure for that.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
//Set email address
String[] toAddresses = new String[] {emailAddr};
mail.setToAddresses(toAddresses);
mail.setSubject(‘Subject – User Creation’);
mail.setPlainTextBody(‘User has been cretaed!’);
Hope this helps.
-
Hi Neha,
We can do it easly. In apex you need to check this:
Database.DMLOptions dlo = new Database.DMLOptions();
dlo.EmailHeader.triggerUserEmail = true;
Database.insert(lstUserToBeInserted,dlo);And alo set the current community workspace administration Email’s setting as below-
1. Open Community Workspaces or Community Management.
2. Click Administration | Emails.
3. Enter custom values for the email sender’s name and address to replace the default values.
4. Also check the send welcome email checkbox and also select the desired email template for email body.Hope it helps 🙂
-
This reply was modified 8 years, 1 month ago by
Adarsh.
-
This reply was modified 8 years, 1 month ago by
-
Hi Adarsh,
Thanks for your response, it is working for me.
Is there a way if “send welcome email checkbox” is false still it is sending a welcome mail to the user?
-
Hi Neha,
This checkbox “send welcome email checkbox” to allow a user to send a welcome email while creating a community user is enable necessary. I am not found any way to overcome this functionality.
So email sends only when this checkbox is enabled.
Thank you.
-
-
Hi Neha,
Yes, we can not overwrite this standard functionality.
-
Hi Neha,
You can also post the separate question for same for faster response.
-
Hi Pranav,
My question is related to the same issue, still, I am confused about “Send Email” checkbox functionality related to Adarsh explanation. My question is totally relevant this discussion.
Thanks for your suggestion
Log In to reply.