You need to sign in to do that
Don't have an account?
Terence Viban
Apex EMAIL_QUEUE on Developer Edition
Hi everyone,
I can't send emails from my developer org. I have tried on two separate dev orgs and everytime I look in the System debug logs, all I see is EMAIL_QUEUE. Why are the emails queued indefinitely?
I have also tried the following code snippet :
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'vnegi@salesforce.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('Apex Email TEST');
mail.setPlainTextBody('The Apex Test is finished processing');
List<Messaging.SendEmailResult> sendRes = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }, true);
from https://help.salesforce.com/apex/HTViewSolution?id=000171487&language=en_US
and the emails are still just queued. Email deliveribility is set to "All Emails"
I have been stuck at this point for a few days and will appreciate any suggestions on what could be wrong.
Thanks
I can't send emails from my developer org. I have tried on two separate dev orgs and everytime I look in the System debug logs, all I see is EMAIL_QUEUE. Why are the emails queued indefinitely?
I have also tried the following code snippet :
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'vnegi@salesforce.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('Apex Email TEST');
mail.setPlainTextBody('The Apex Test is finished processing');
List<Messaging.SendEmailResult> sendRes = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }, true);
from https://help.salesforce.com/apex/HTViewSolution?id=000171487&language=en_US
and the emails are still just queued. Email deliveribility is set to "All Emails"
I have been stuck at this point for a few days and will appreciate any suggestions on what could be wrong.
Thanks
Messaging.SendEmail() just queues the email to Email Server and it is sent asynchronously.
It's not sent as soon as your code fires and hence won't be captured in the logs.
Another possibility is the email is being filtered by the recipient domain or going to the SPAM folder rather than the Inbox.
You would receive a failure message via email (on from address used for sending) if there was an error e.g. the mail id soft/hard bounced.
A better way to determine whether the email is actually sent successfully is having a look at the Email Logs (Setup -> Monitor -> Logs -> Email Log Files).
These limits are much lower in Developer Edition and can be easily hit.
Try using setTargetObjectId while sending email to test if its being delivered (rather than toAddresses) which is exempted from these limits. Since you are just testing, you may set it to your own email id as well "setTargetObjectId(UserInfo.getUserId())".
Please try to execute below code in developer console. Below code is working fine for me Please add your email id in below line. Please let me know if you any other help.
Some related link for you
https://www.salesforce.com/developer/docs/api/Content/sforce_api_calls_sendemail.htm
https://www.salesforce.com/developer/docs/api/Content/sforce_api_calls_sendemail_emailresult.htm
http://www.sfdc99.com/2014/03/01/sending-emails-using-apex/
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
Thanks
Amit Chaudhary
amit.salesforce21@gmail.coom
@Amit - I ran the code above and the logs show me the same message as before "21:19:31.132 (132184407)|EMAIL_QUEUE|[5]|subject: my subject, bccSender: false, saveAsActivity: true, useSignature: true, toAddresses: ... "
I have also looked at all the links you sent before posting.
I have implemented Apex Email successful for 3 clients in the past and I have an App on the App Exchange that sends automated emails from a batch job. So I have some experience with Apex email. In this particular case I have tried two separate developer orgs. I was already beginning to think that things have changed with respect to sending Apex email from a Dev Org, but if it works for you then I really don't understand what the problem is here. Any other thoughts?
@Jayant: I have tried sending Email with and without setTargetObjectId and in all case the emails are just queued. I also took a look at the email logs and there are no errors. Just the indication that email is queued. I have tried provoking errors, like attaching files greater than 10MB and I get an exception as expected. So there are no errors being thrown and I haven't reached my daily LIMITS either because I haven't even succeeded to send an email once. The problem here is really that for the two Dev orgs I use, the emails are queued indefinitely. Any other thoughts?
Thanks guys
Terence
Above code is working fine for me. Can you please let me know from where you are executing above code.
Please try in developer console...
NOTE :-
1) Email cannot be sent from a constructor
2) Test class cannot send an email
3) Please check your organization's email deliverability Setting. (TLS)
If Possible then please post your full code.
Thanks,
Amit Chaudhary
I executed the piece of code directly from execute anonymous on Mavensmate. The deliverability setting is set to All Email, this is the first thing I checked. And also the issue with not being able to send email from the constructor or test class, I know already.
I will try a new brand Org and open a case with Salesforce at thesmae time. The fact that I cannot even run the snippet above that runs fine for you is may be an indication that something is wrong with my org. It doesn't really make a difference if I post my own code here or not. I can get the snippet above to send an email.
Thanks for you help Amit.
Cheers