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
Ghanshyam BhattGhanshyam Bhatt 

SINGLE_EMAIL_LIMIT_EXCEEDED : Using SetTargetObjectId(contact.Id) on SingleEmail Message.

Dear Members,

 

I came accross a very surprising(annoying as well) problem when i tried to send the EMail using SingleEmailMessage.

 

I used setTargetObjectId(User.Id) and send near about 800 emails from my development org. My Email Limit remained as it is.

But when I used setTargetObjectId(Contact.Id) and tried to send the emails then i came Accross SINGLE_EMAIL_LIMIT_EXCEEDED.

 

Can anybody suggest and Provide input on this as salesforce documentation provide contradictory info in below Link:

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_apex_governor_limits.htm

 

"There’s no limit on sending
individual emails to contacts, leads, person accounts, and users in your organization directly from account, contact,
lead, opportunity, case, campaign, or custom object pages.
"

 

"You can send an unlimited amount of email to your organization’s
internal users, which includes portal users.
"

 

Thanks In Advance,

 

Ghanshyam Bhatt

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Satish_SFDCSatish_SFDC

For the first statement, the doc also says:

Single emails sent using the Salesforce application don't count toward this limit.

 Which probably means not Apex but the Salesforce User Interface. I understand that you can send unlimited individual emails to Accounts, Contacts etc. through the User interface but not through Apex. 

 

Hope this helps.

 

Regards,

Satish Kumar

All Answers

Satish_SFDCSatish_SFDC

For the first statement, the doc also says:

Single emails sent using the Salesforce application don't count toward this limit.

 Which probably means not Apex but the Salesforce User Interface. I understand that you can send unlimited individual emails to Accounts, Contacts etc. through the User interface but not through Apex. 

 

Hope this helps.

 

Regards,

Satish Kumar

This was selected as the best answer
souvik9086souvik9086

There is a point there that

  • You can send 100 emails per SingleEmailMessage.

But I guess you are sending 800 emails at a time. Please make sure of that.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

 

 

Ghanshyam BhattGhanshyam Bhatt

I sent 1 email using 1 singleEmailMessage instance and i created 800 such instances to it. So, i send 800 emails.

Avidev9Avidev9

After reading your problem, what comes in mind is

  • only 10 calls to sendEmail is allowed per transaction
  • I dont think Developer org has 1000 emails per day limit. SF sets a lower limit for DE org and Trial orgs
Ghanshyam BhattGhanshyam Bhatt

I am providing a pseduo cose for what i did. It may Avoid confusion.

 

1) Create 800 instances of singleEmail Messages.

2) Put these Instances into the List.

3) as sendEmail() takes list as an argument so i provided list.

 

this shot near about 800 emails, i just one call of send email.

 

So, Technically i do it 2 days back.\

 

Thanks.

Avidev9Avidev9

I dont think you can send more than 10 emails to external user @ DE Org.

They enforcea  hard  limit of DE org and 1000/day email limit is for UE.

souvik9086souvik9086

In Developer org, you cannot send more than 10 mails at a time. Please check that.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

Ghanshyam BhattGhanshyam Bhatt

Friends, i am using setTargetObjectId(user.id) for sending email. So salesforce considers it as the internal message. and it doesnot enforces the limit.

Avidev9Avidev9
Buddy can you post your code ?
Because initially you said you are setting contact.id!

Posting the code will really help others to debug the issue, because its pretty clear from the error message that you are hitting limit.
Chirag MehtaChirag Mehta
Did anyone ever found solution for this ? Seems there's no solution to send unlimited emails to contacts from apex ? Logically it should have been, but it isn't - really sad :( :( :(

You can email a maximum of 1,000 external email addresses (non-users) each day (based on GMT) via the API/Apex regardless of your Salesforce.com edition.  Unfortunately this limit does not scale with user count like most SFDC limits. The single and mass email limits don't take unique addresses into account. For example, if you have johndoe@example.com in your email 10 times, that counts as 10 against the limit.

Emails sent via the UI (Send an Email button), Workflow and Auto-Response Rules do not count against this limit. Conversely, inbound email limits do scale by 1,000 emails per Salesforce user license.

Contact your Salesforce.com administrator, Salesforce.com account representative, or Salesforce.com technical support to obtain an increase to this limit or for clarification on the limit.
SwapnilSrivastava_SFDCSwapnilSrivastava_SFDC
The doubt can be cleared from below Salesforce Link where it clearly specifies that:-

>>https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

"If you use SingleEmailMessage to email your org’s internal users, specifying the user’s ID in setTargetObjectId means the email doesn’t count toward the daily limit. However, specifying internal users’ email addresses in setToAddressesmeans the email does count toward the limit."

>>https://help.salesforce.com/articleView?id=000323568&type=1&mode=1 (https://help.salesforce.com/articleView?id=000323568&type=1&mode=1)

"Emails sent using 'setTargetObjectId()' set against the User object do not count against the 'SingleEmailMessage' limit."


Hope this clears the doubts for many of us.

Thanks 
Swapnil Srivastava