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
devNut!devNut! 

MassEmail not enabled?

I'm trying to use the mass email call and am getting an error:

15:42:56 INFO - 20080905194256.499:AnonymousBlock: line 14, column 1: ----------------------------------------- 20080905194256.499:AnonymousBlock: line 15, column 1: (Messaging.SendEmailResult[getErrors=(Messaging.SendEmailError[getFields=null;getMessage=Single email is not enabled for your organization or profile. Single email must be enabled for you to use this feature.;getStatusCode=System.StatusCode.NO_MASS_MAIL_PERMISSION;getTargetObjectId=null;]);isSuccess=false;])


Code:
Id templateId= '00X300000012aLJEAY';
Id[] cIds = new Id[1];
cIds[0]='0033000000R0ByYAAV';

Messaging.MassEmailMessage  mail = new Messaging.MassEmailMessage();
mail.setTargetObjectIds( cIds ); // the target contact 
mail.setTemplateId( templateId); //template to be used
mail.setBccSender(false);
mail.setSaveAsActivity(false);
mail.setUseSignature(false);

Messaging.SendEmailResult[] res = Messaging.sendEmail(new Messaging.Email[] { mail } , false);

System.Debug('-----------------------------------------');
System.Debug(res);

 

The apex code is running in system context so I don't see why I'd need to enable mass email permission on a user profile.

Any ideas?
mikefmikef
I don't think it's a user permission issue.

Are you doing this in a DE org?
Might be the org doesn't have Mass Email turned on.

You can check with support to find out for sure.