I have a class that should look up a record, and send a Messaging.SingleEmailMessage with a certain template to a certain contact, and blind carbon copy some address.
The problem is that I'm not receiving an error message, even though Salesforce believes that the email is being sent.
I'm using Messaging.SendEmailResult
to check if the message wasn't delivered, but to my surprise isSuccess()
method returns true
.
Using system.debug
on the email message returns the following:
15:34:46:395 USER_DEBUG [37]|DEBUG|
Messaging.SingleEmailMessage[
getBccAddresses=(
[email protected], [email protected]
);
getCcAddresses=null;
getCharset=null;
getEntityAttachments=null;
getFileAttachments=(
Messaging.EmailFileAttachment[getBody=core.filemanager.ByteBlobValue@71ca58a7;
getContentType=null;
getFileName=FILE.pdf;
getInline=false;
]);
getHtmlBody=null;
getInReplyTo=null;
getOptOutPolicy=SEND;
getOrgWideEmailAddressId=0D2o0000000PLQjCAO;
getPlainTextBody=null;
getReferences=null;
getTargetObjectId=0034D0000072AI7QAM;
getTemplateId=00X4D000000M97WUAS;
getToAddresses=null;
getWhatId=a0m4D000000ARVrQAO;
isTreatBodiesAsTemplate=false;
isTreatTargetObjectAsRecipient=true;
isUserMail=false;
]
And on the send result:
15:34:46:682 USER_DEBUG [39]|DEBUG|(Messaging.SendEmailResult[getErrors=();isSuccess=true;])
Records are being created on the Activity History related list, and they show that the message was sent. But I never receive it.
- I've checked Deliverability settings, and Access to Send Email is set to 'All email'.
- I've checked my code, and every Id is valid, and the template page shows me the HTML email as expected, with no errors.
- I've checked the SOQL being used to retrieve the records, no issue there too.
- I've checked spam folders on Gmail, and nothing there either.
What can be wrong?