• Dhopmen
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

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?