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
kdmrkdmr 

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

Hi,

 

 am trying to send the mass email to contacts.I am getting the error as  below.Am doing this in a DE org.

 


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.

 

 

My coding as  below

 

 private final List<Id> contactids;
  public List<Contact> con;
  public testemail(ApexPages.StandardController controller)
  {
     con = [select Id from Contact limit 5];    
     contactids=new  List<Id>();     
     for(Integer i=0;i<con.size();i++)
     {    
      contactids.add(con[i].Id);       
     } 
  }

  public void SendEmail()
  {
      Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
      mail.setTargetObjectIds(contactids);   
      mail.setTemplateId('00X90000000ZQgA');
      Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
  } 

 

 

  Can anybody tell me how to enable single email/mass email?

 

  Thanks  for any help

 

 

bob_buzzardbob_buzzard
I don't think you'll be able to do this.  Last time I tried this on a dev org, I got a message that the mass email functionality is only available to paying customers.  
Rasmus MenckeRasmus Mencke
Mass email is not enabled for Developer Edition org.
ccusic1ccusic1
Check you Deliverabililty settings under Setup > Email Administration > Deliverability.  My issue was that we had the setting set to No Access.  It must be set to All Email. 
U JayU Jay
@ccusic

Resolved my email issue ! Good catch (Y)
ccusic1ccusic1
@U Jay, please don't forget to choose the Best Answer so that others that view this post can quickly identify how to solve a similar issue.
Suraj MallaSuraj Malla
Here is a link of the knowledge article explaining all the possibilities of this error
https://help.salesforce.com/apex/HTViewSolution?id=000002868&language=en_US
Sara RudrarajuSara Rudraraju
I am getting the same error when excetuing it with an API User. I am able to send the email successfully when running the 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.

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

Org Wide Perms:
Deliverability>Access level = All Email
Respect SendEmail API - Enabled
SendEmail API - Enabled
sagarvp9sagarvp9
This Issue can be resolved by setting Access Level to All Email on Deliverability.
User-added image
ronak patel 83ronak patel 83
sir i have a same problem and i also enable the access level to all emails
 it may possible any othe reason?
ronak patel 83ronak patel 83
thnk u sir i got it mine error is solved
Faheem Sayed 7Faheem Sayed 7
Thank you MR. CCUSIC , issue is solved :)
Wladimir BotonWladimir Boton
On my case, the problem was not related to Access Level or Profile permissions. It was related to email template access permission. 
I've create a visualforce page where the user could choose the folder and the email template to send mass email using an Apex Batch.
There was no problem showing the folders and emails to the user in the visualforce page.

This is the code I've used to send the mass email:
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
mail.SetTargetObjectIds(targetObjectIds);
mail.setTemplateId((Id) templateId);
mail.saveAsActivity = true;	 		
Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
And I get the error:
Api
SerialBatchApexRangeChunkHandler
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.: []
On the Messaging.sendEmail line.

The problem was that the user was not included on the Public Group that have access to the email template folder.

After add the user to the Public Group, it worked just fine.

The error message NO_MASS_MAIL_PERMISSION says one thing but the problem was another ... 
levlazlevlaz
Just wanted to chime in and say thank you to @ccusic; fixed the issue right away. :) 
Himanshu Babaria 2Himanshu Babaria 2
@Wladimir Boton - What you have described was the exact issue in my org. Thank you very much sir !
shailendra singhaishailendra singhai
@ccusic1  thanks it work for me
Debprotim Seal 5Debprotim Seal 5
@Wladimir Boton, Himanshu Babaria 2 - how did you check permission to email template was there or not? And email templates you guys are talking of is the classic email templates?
Dave KingeryDave Kingery
So, using  Setup > Email Administration > Deliverability to set Access Level to "All Email" is one option, but I'm not sure it's ideal.

I have four unit tests that are failing because of this, and they pass because of the change, but won't this affect email settings outside of unit tests?  If the emails are supposed to be sent on a trigger, then won't actual emails be sent when I'm inserting test data manually for functional tests?  Could real customers wind up getting emails from Sandbox if their records were copied to a full Sandbox?