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
Adam PurkissAdam Purkiss 

Getting INSUFFICIENT_EMAIL_ACCESS in mass email sending

The following single line of code produces this error:

 

Messaging.reserveMassEmailCapacity(1);

When I omit this and actually send a mass email, Messaging.sendEmail returns success in the SendEmailResult list (isSuccess == true). However, the email doesn't actually send and instead I get the following email:

 

Mass email request "Mass Email (API)" failed.
The system returned an error code of "INSUFFICIENT_EMAIL_ACCESS".

You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

Click http://na9.salesforce.com/07AE0000000CbZW to view more details about this mass email request.

Best Regards,
Salesforce.com
www.salesforce.com



Clicking on the link takes you to a page that simply displays the following:

 

Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.


 

I'm running as a System Administrator, from within Apex.The email is just a test and should be sent to one user, which is me in this test case. When I send as a single email it works fine. Following is the code for sending the mass email:

 

// Reserve email capacity for the current Apex transaction to ensure
// that we won't exceed our daily email limits when sending email after
// the current transaction is committed.
//Messaging.reserveMassEmailCapacity(userIds.size());
// TODO: Report error to Salesforce? This method results in an unauthorized error.
	
// Create a new single email message object 
// that will send out a single email to the addresses in the To, CC & BCC list.
Messaging.Massemailmessage mail = new Messaging.Massemailmessage();
	
// Specify the address used when the recipients reply to the email.
mail.setReplyTo(o.EmailReplyTo__c);
			
// Specify the name used as the display name.
mail.setSenderDisplayName(o.EmailSenderDisplayName__c);
				
// Apply template.
mail.setTemplateId(o.EmailTemplateId__c);
			
// SaveAsActivity must be false when sending email to users
mail.setSaveAsActivity(false);

// Set target object Ids
mail.setTargetObjectIds(userIds);
	
// Send the email.
Messaging.sendEmail(new Messaging.Massemailmessage[] { mail }, false);

 

 

Any help would be greatly appreciated.

 

Thanks in advance,

Adam Purkiss

Best Answer chosen by Admin (Salesforce Developers) 
Adam PurkissAdam Purkiss

The solution is to submit a case and request this feature to be turned on. Explain why you want mass email turned on and they'll do it for you within 2 days, assuming your reason is reasonable.

All Answers

Santosh KumbarSantosh Kumbar

Are you trying in developer edition? if not go to ur profile and check the mass email check box. it should be checked for Mass Email Property.

 

 

Adam PurkissAdam Purkiss

Yes, this is in developer edition. I'm developing software for the AppExchange so it needs to be in DE. The Bulk Email option under System Administrator profile is checked though.

 

Adam

Santosh KumbarSantosh Kumbar

As per my knowlodge Salesforce doesnt allow you to send mass mails through developer edition.

Scott.MScott.M

Can anyone confirm this to be the case? I'm looking through the docs and can't find any reference to the developer org mass email limitation. If this is the case it would be useful to know so I don't spend hours trying to figure it out in my developer org :)  

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

 

Thanks!

Scott

 

Update:

 

This was confirmed in this thread:

http://boards.developerforce.com/t5/General-Development/Mass-email-in-Developer-Edition/m-p/47381/highlight/false#M12430

 

Adam PurkissAdam Purkiss

The solution is to submit a case and request this feature to be turned on. Explain why you want mass email turned on and they'll do it for you within 2 days, assuming your reason is reasonable.

This was selected as the best answer