You need to sign in to do that
Don't have an account?
Troubleshooting outbound email beyond the obvious
I'm trying to use Messaging.sendEmail() in my sandbox and all indications are that it is working:
- Messaging.SendEmailResult.isSuccess() returns TRUE
- Messaging.SendEmailResult.getErrors() returns an empty list
- Before/after calls to Limits.getEmailInvocations() indicate that one invocation is being consumed
- Logs in the Developer Console show what I would expect to see -- the sendEmail() call followed by the body of the message
But the emails just aren't getting to their destination. I have another bit of code that has been around for a while and is quite similar, and it's working just fine -- I test it and an email arrives in my Inbox almost instantly.
What can I do to troubleshoot this further? Also, just to fill in some details, the basic architecture of the process I'm trying to automate here is as follows:
- VisualForce email template called E
- VisualForce page called P
- code that invokes Messaging.sendEmail() is in the controller associated with P (in the constructor method)
When page P is loaded, the controller's constructor executes and sends an email using the email template E to a test Contact record. At first I was trying to attach a PDF generated by yet another VisualForce page but I commented out this functionality just to see if simplifying things would eliminate the problem. Still no emails in my Inbox.
I've also added a call to setBccAddresses() and passed it two additional email addresses of mine, on different domains and hosted by different services from the email address associated with the test Contact -- and the emails don't arrive in those mailboxes, either. All three email vendors provide very straightforward spam control so I have no reason to suspect that the emails are getting blocked -- it just seems like, somehow or other, Salesforce is failing to send these emails /after/ they leave the purview of Apex.
What can I do to troubleshoot this problem further?
Tried deploying the code to Production on the off-chance that something was wrong with my sandbox. No luck there, either. Same "symptoms": Everything indicates that the email has been sent, except that it never arrives at any of the three mailboxes it was sent to.
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