I'm writing some code that should (de-)activate some users based on some criteria. This part was easy, but one of the requirements is also that this user should NOT get an email.

So when I create a new user, he/she does not get an email which is good. But after some events, if a deactivated user(IsActive = false) becomes active(IsActive = true), I do get an email, even though I use Database.DMLOptions in both cases.

for (User u : usersToUpdate) {
    u.IsActive = true;
Database.DMLOptions dmlo = new Database.DMLOptions();
dmlo.OptAllOrNone = true;
dmlo.EmailHeader.triggerUserEmail = false;
dmlo.EmailHeader.triggerAutoResponseEmail = false;
Database.SaveResult[] srList = Database.update(usersToUpdate, dmlo);

For new users I use the same code, except for Database.update, which is an insert there(obviously).

But even though I set both triggerUserEmail and triggerAutoResponseEmail to false, an email is still being sent to the email address of this user.

Am I doing something wrong? Is there a way not to send emails to users when their records get active?

1 Answer 1


This is stander SFDC functionality. When you create/activate user System send email. On the other hand when you deactivate user system do not send any email. These are system generated email and we can not control it any flag.

The other thing you can try is freeze user instead of deactivating.

You must log in to answer this question.

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