You need to sign in to do that
Don't have an account?

Sending Single Email Message from Sandbox
Hello,
I'm having a problem sending an email message from the developer console or execute anonymous or final batch statments from within the sandbox.
I have successfully sent the email from the developer console in the production org, but i cannot do the same in the sandbox.
Does anyone know why i would not be able to send from the sandbox?
Here is the code:
Messaging.reserveSingleEmailCapacity(2);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'email@domain.com'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('email@domain.com');
mail.setSenderDisplayName('Salesforce Support');
mail.setSubject('New Case Created ');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Your Case: has been created.');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
Thanks for your help.
Sounds suspiciously like the problem I'm having in my sandbox: http://boards.developerforce.com/t5/Apex-Code-Development/Troubleshooting-outbound-email-beyond-the-obvious/td-p/437851
I'm going to deploy the code mentioned in my question to production today and see if it works there -- will update both threads.
No luck in for me in Production, either -- so nevermind, I guess.
Works fine from my sandbox.....maybe log a case
Newly created sandboxes have the default email deliverability setting System email only.
To configure email deliverability settings, in the sandbox organization, from Setup, click Email Administration | Deliverability. If editable, set the Access level in the Access to Send Email section to All Email.
Once set this setting, then you will start receiving emails even from sandbox.
PS: You may not be able to edit the Access level if salesforce.com has restricted your organization’s ability to change this setting.
Hi seattle_developer,
were you adding an error to the records using addError.
If so then that would cause the entire transaction to roll back and along with it the queued emails.
you can refer:
https://developer.salesforce.com/forums/?id=906F000000093LGIAY