Activity Forums Salesforce® Discussions How to send Community Welcome Email to a User through Salesforce Apex?

  • Neha

    Member
    March 23, 2018 at 6:09 am

    My correct question is "How to send Community Welcome email to user through Apex ?"

  • PRANAV

    Member
    March 23, 2018 at 10:52 am

    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.

  • Archit

    Member
    March 23, 2018 at 11:20 am

    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.

  • Adarsh

    Member
    March 26, 2018 at 6:57 am

    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 6 years, 7 months ago by  Adarsh.
  • Neha

    Member
    March 26, 2018 at 7:20 am

    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?

  • Adarsh

    Member
    March 26, 2018 at 8:12 am

    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.

  • Archit

    Member
    March 28, 2018 at 11:09 am

    Thanks Pranav,

    Your solution worked for me..!!

  • Neha

    Member
    March 29, 2018 at 6:21 am

    Hi Adarsh,

    It means we can not overwrite the "Send email"checkbox functionality of Community Welcome mail?

    • This reply was modified 6 years, 7 months ago by  Neha.
    • This reply was modified 6 years, 7 months ago by  Neha.
    • This reply was modified 6 years, 7 months ago by  Neha.
  • Adarsh

    Member
    March 29, 2018 at 6:44 am

    Hi Neha,

    Yes, we can not overwrite this standard functionality.

  • PRANAV

    Member
    March 29, 2018 at 8:37 am

    Hi Neha,

    You can also post the separate question for same for faster response.

  • Neha

    Member
    March 29, 2018 at 10:45 am

    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.

Popular Salesforce Blogs