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
Sara RudrarajuSara Rudraraju 

NO_MASS_MAIL_PERMISSION, Single email is not enabled for your organization or profile

I am getting this error when excetuing below script as an API User. I am able to send the email successfully when running the same script with my account.
API User's profile has Mass Email and Send Email enabled. It also has Read and View All permission on Accounts and Contacts.

Org Wide Perms:
Deliverability>Access level = All Email
Respect SendEmail API - Enabled
SendEmail API - Enabled

Scritp:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId('0033000001rfDgk');
mail.setTemplateId('00X0M000001XnpM');
mail.setOrgWideEmailAddressId('0D230000000EvAC');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

Error:
System.EmailException: SendEmail failed. First exception on row 0; first error: NO_MASS_MAIL_PERMISSION, Single email is not enabled for your organization or profile.: []

What else can I enable to give the API user access to run the script successfully.

Thanks in Advance!
NagendraNagendra (Salesforce Developers) 
Hi Sara Rudraraju,

Description:Why we get the following error when sending mail through a trigger "System.EmailException: SendEmail failed. First exception on row 0; first error: NO_MASS_MAIL_PERMISSION, Single email is not enabled for your organization or profile. Single email must be enabled for you to use this feature.: []" 

The trigger is executed by a user with System Administrator profile, both Mass mail and Single Mail are enabled for the profile.

Reasons for the above error:
  • Trial accounts do not allow the use of mass email. You will have to purchase a license to go live with your org.
  • You are missing a permission in the backend and must log a case with Salesforce support to enable "Respect SendEmail API" and "SendEmail API".
  • The access level might have been set to "system e-mails".
     In setup | Administration setup | Email Administration | Deliverability, verify if the access level is set to "All e-mails".
  • The e-mail deliverability is a new feature released in spring 13 and as per the release notes, all newly refreshed sandboxes default to "system email only"
For more information see page number 46 in the below link:

https://help.salesforce.com/HTViewHelpDoc?id=data_sandbox_implementation_tips.htm&language=en_US

Please mark this as best answer if the information helps.

Best Regards,
Nagendra.P