You need to sign in to do that
Don't have an account?
MJ Kahn / OpFocus
Accessing SingleEmailMessage's getFileAttachments() list
After I create a SingleEmailMessage and send it, I can get various attributes of the email - for example, its plainTextBody, htmlBody, etc., but when I look at its getFileAttachments() or getDocumentAttachments() lists, they're always null, even when the email that's actually sent includes attachments.
Here's the code:
When I receive the email, it does have an attachment, the file attachment that the email template defines.
Is there any way to get getFileAttachments() to return the attachments?
Thanks!
Here's the code:
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setTemplateId(templateId); email.setTargetObjectId(contactId); email.setWhatId(recordId); Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{email}); System.debug('===== email.getHtmlBody() = ' + email.getHtmlBody().left(20)); System.debug('===== email.getDocumentAttachments() = ' + email.getDocumentAttachments()); System.debug('===== email.getFileAttachments() = ' + email.getFileAttachments());The System.debug()s show me:
===== email.getHtmlBody() = <style>p{margin-top: ===== email.getDocumentAttachments() = null ===== email.getFileAttachments() = null
When I receive the email, it does have an attachment, the file attachment that the email template defines.
Is there any way to get getFileAttachments() to return the attachments?
Thanks!