7

I am trying to send an email from a system admin account which has send email and mass email enabled. I get:

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.: []
Error is in expression '{!sendEmails}' in component <apex:page> in page dmapp:dm_send_usage_details_admin

An unexpected error has occurred. Your solution provider has been notified. (DMAPP) 

Code to send email is like:

    Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
    msg.setToAddresses(new String [] {emailAddress});    
    msg.setSaveAsActivity(false);
    msg.setPlainTextBody(emailMsg);
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] {msg});

Any tips?

Saariko
  • 5,610
  • 13
  • 75
  • 165
More Than Five
  • 2,033
  • 19
  • 30

1 Answers1

7

Salesforce Spring '13 introduced a new email deliverability setting (Setup > Email Administration > Deliverability). New sandboxes created on Salesforce Spring '13 will have this automatically set to "System email only," causing this error.

This setting must be changed to "All Emails" in order not to throw that exception.

Details are on page 46 of the Spring '13 Release Notes (worth thanking Bill Bennett for this one)

Matt and Neil
  • 32,894
  • 7
  • 105
  • 186