function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sarika PatelSarika Patel 

How to check whether a file is attached to an email or not?

Hi,

I want to add a validation rule, to check an email should be sent, if it has some attachment in it, if not then it should not be sent.

If not validation rule then is there any other possibility to check if the email has an attachment or not?

Is it possible?
Thanks
Best Answer chosen by James Loghry
pconpcon
Are you refering to outbound or inbound email message?

If you are referring to inbound email messages, there is a HasAttachment Boolean field on the EmailMessage object that you should be able to use (if not in a workflow at least via Apex).

If you are referring to outbound email messaging, I am not sure there is anyway to intercept these before they are sent and do any sort of validation.  If you are sending the emails via Apex, then of course you could check the Messaging.SingleEmailMessage methods to check / set an attachment.