function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Disabling email notifications to a Community User through APEX code

Hi All,

I'm trying to stop the email notifications to a community User through APEX code for the following scenarios:

1. Welcome email for a New User creation
2. Email notification on receiving a Private message.

I have used the following code to disable the Email notification:

userId.UserPreferencesDisableAllFeedsEmail = true;

Even then the emails are thrown to the user.
Please suggest some workaround for this.
Raghavendra ARaghavendra A
Hi Naveen,

UserPreferencesDisableAllFeedsEmail attribute is to diable all the emails related to Chatter Feeds. You can customize the welcome email for a new user creation in the email templates.


The email notifications(Welcome mail and private messages notification mail) should be stopped only for the the users who are created by APEX code. For the other users who are created by the Admin through Org, the email notifications should NOT be stopped.
Did you find an answer to this yet?  I have 2 million users to create and don't want any of them to receive emails.