23

There is a limit on the number of emails you can send from Apex, this is 5,000 per 24 hours and you would need to raise a case and engage with Salesforce to get this raised. I think that the error message you are seeing there refers to a different limit, which is that you can only call sendEmail 10 times within the same context. Is it possible that your ...


18

What MassEmailMessage appears to give you is a more optimal coding route if you are focusing on sending to Contacts, Leads or Users relating to either Contract, Case, Opportunity or Product objects. So if you had 50 such Contacts to email you need only have a single MassEmailMessage instance and set a list of those Id's into it. Instead of creating 50 ...


17

Now we can use setTreatTargetObjectAsRecipient(treatAsRecipient) and treatAsRecipient as false. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm


12

If you have the ContentDocument Id you can fetch the ContentVersion file as this: // If you only want the ContentVersion ID's Map<Id, ContentVersion> contentVersions = new Map<Id, ContentVersion> {}; Set<Id> versionsToAttach = new Set<Id> {}; contentVersions.putAll([ SELECT Id, ContentDocumentId FROM ContentVersion ...


9

I can confirm Salesforce changed the daily limit for Developer Edition orgs to 10 a few releases ago, this is indeed a significant drop from the before 1000. It caused issues with our development and testing teams. Eventually we made a case to get it raised back up to 1000 for some of our DE orgs, suggest you contact support and request the same, at least ...


9

Single Messaging has limits as you cannot call sendEmail method more than 10 times in single transaction and 1000 e-mail per license per day. Some how you are hitting these limits. If you are sending email to organization internal users in that case you should use setTargetObjectId(userId) instead of toAddress. Pass user Id in that method. ...


8

Hi You are getting the error because you are using Messaging.renderStoredEmailTemplate() in for loop as this is counted towards the SOQL governor limit as one query. To avoid the exception you have to remove out Messaging.renderStoredEmailTemplate() of for loop. For more reference please have a look on salesforce docs for the Messaging class. Executing ...


7

setTargetObjectIds method of MassEmailMessage accepts max of 250 Ids and setToAddresses of SingleEmailsMessage accepts 100 email address.This is what i would consider when designing.And also agreed with Andrew on his answer objects we focus matter while selecting


7

You can send a test message with no parameters, and check the resulting error code. BCC Compliance is checked before other validations, so this should be reliable. Boolean bccComplianceEnabled; Messaging.SingleEmailMessage m = new messaging.singleEmailmessage(); m.bccsender = true; try { Messaging.sendEmail(new messaging.singleemailmessage[] { m }); } catch(...


7

Using Newly introduced method setTreatTargetObjectAsRecipient() in Winter 16, you can send email message to any email address. Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setWhatId(recordId); email.setTemplateId(templateId); email.setToAddresses(new String[] { toAddress }); //Set current user as ...


7

To answer the specific question, the sendEmail method returns a list of Messaging.SendEmailResult objects. This list will be in the same order as the corresponding list of emails provided to sendEmail(..). As Mohith pointed out, you can only discover whether the email message was successfully queued for delivery, and, if not, why. You can't discover if the ...


7

In your code you need to bring in a slight change. Where you setting AccountId in setWhatId() method, change it to mail.setWhatId(ContactId); A brief explanation from the docs. setWhatId(whatId) If you specify a contact for the targetObjectId field, you can specify an optional whatId as well. This helps to further ensure that merge fields in the ...


6

As @crop1645 mentioned, the error message is fairly clear in this case. When you specify the Org-Wide Email Address you're sending the message from, you will not be able to also set the Sender Display Name. Your code example should work correctly after you remove this line: conformemail.setSenderDisplayName('Ramesh');


6

https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_brandtemplate.htm BrandTemplate bt = [select id from BrandTemplate where name='Blank' limit 1]; Update: A letter head goes in conjunction with HTML Email template. So to access letterhead from email template query emailtemplate et = [select BrandTemplateId from emailtemplate where ...


6

According to the Salesforce Limits Quick Reference Guide the limit for SingleEmailMessage is 100 emails per SingleEmailMessage and 1000 emails per day. Also it says when specifying email addresse in addressesTo it counts against this limit but when you use setTargetObjectId it does not count against the limit. By using setTargetObjectId you should be safe ...


6

Rishi Golyan correctly identified the issue, however, Messaging.renderStoredEmailTemplate() works on single ids rather than a list of ids. So, simply moving that method call to be outside of your loop isn't going to cut it if you have more than 100 Contacts to mail to. One way to handle that situation would be to put it into a class that implements ...


5

Setting the ContentType doesn't perform any format conversion. A non xls attachment sent in this way will just have all the HTML dumped into the body of the spreadsheet. I think the only way to get xls files from Salesforce is either: from a Custom Report, where you know the Id and can form a download URL like /00OG0000005YaRh?export&xf=xls or by hand-...


5

I use templates and can easily set additional to: addresses using email.setToAddresses(toRecipients); even though the doc says it is not supported. Have you actually tried to set cc: adddresses and additional to: addresses with a template and seen it fail? I'm not 100% convinced the doc is accurate . I just tried using anonymous APEX and V.30 using this ...


5

Basic idea would be to query user that you need (f.e. with system admin profile etc), and use email on that field. For example: Profile sys_adm_profile = [SELECT Id FROM Profile WHERE Name = 'System Administrator']; List<User> sys_adm = [SELECT id, Email FROM User WHERE ProfileId = :sys_adm_profile]; String[] toAddresses = new String[] {sys_adm.Email}...


5

The only reason Salesforce is trying to serialize the List<Messaging.SingleEmailMessage> property is because you are adding it to the View State. You don't need to, however, as you do not reference it in your markup. Simply remove the messageList property and scope it locally. If you really want to keep it as a property, mark it as transient. Repro ...


5

This is from Dan Appleman's Advanced Apex Programming Ver 3. The code is available for download from his web site at http://www.AdvancedApex.com This pattern uses a dispatcher class that implements Schedulable to enque queueables like what you have at whatever interval you want to configure using the chron trigger object. Here's the essence of the code you'...


5

Messaging.SingleEmailMessage needs one contact per template in order to merge the data correctly (including Contact-specific information). The good news is that Messaging.sendEmail supports at least 10,000 emails in a list, so all you really need to do is create a list of messages and send them all at once: Messaging.SingleEmailMessage[] messages = new ...


4

Yep, when you are assembling the message, use: message.setSaveAsActivity(true) which will capture it as a Completed Task on the Case.


4

You need to use &nbsp; The following anonymous apex worked for me with my Exchange email client receiving the email: Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setToAddresses(new String[] {'foo@bar.com'}); mail.setSubject('stackforce answer'); String messageBody = '<html><body>Hi, welcome to &nbsp;&...


4

I've been asked to try to generate "true" XLSX format as 2nd pass to make Scheduled reports as attachment even friendlier. For sure it's not worth trying to emulate the old xls (binary) format... I've spent some time searching and so far this thing looks most promising: http://neerajgupta999.blogspot.in/2012/06/multisheet-excel-from-apex.html. If I'll have ...


4

I don't think email can work like that, regardless of if you are using Salesforce or not. Either the CC_User is specified in the CC addresses or they aren't. Instead, you could try building up a mailto: hyperlink in the email body that would populate the to and cc addresses as required.


4

This is fun question! I've tried to noodle this a few different ways and show examples of developer-friendly test cases. But I confess: there is the possibility it will be a frustrating job in real orgs: in Sandboxes, the Email Deliverability setting might mean NO emails can ever be sent the "breaking mutation" made in the test case may not reflect the ...


4

If I were the Sysad, I would want to only get a summary of all Accounts created once per day (or maybe once per x hours) rather than be spammed every time an Account was created. In this model, you would use a scheduled APEX class to run every x hours, looking for Accounts where some field has_sysad_been_notified__c is false. Collect all the account names ...


4

Your testmethod solution has elements that don't belong. While you didn't post your actual PROD code (only screen shot), the prod code has two methods that need to be tested Your solution 1 `execute()` that calls `setSendEmailReminder()` To get code coverage and the all important asserts, you simply need to // mock some Tasks TaskEmailSendReminder schCls ...


4

You can do it with just one query: SELECT Email FROM User WHERE Profile.Name = 'System Administrator'


Only top voted, non community-wiki answers of a minimum length are eligible