Using Attach File to record with email feature in document action
- You need to keep the “attach file to record” box checked in document action if you would like to email the generated document. When emailing any document as an attachment from Salesforce, document needs to be saved in Salesforce and it can’t be added ‘on the fly’. That is why it is required to save document in Salesforce (uploaded to Notes & Attachments related list, Files or Documents).
- You can delete these attachments periodically as needed. You could manually delete them from records or create an automatic job that would do it. To set up the job you would write and Apex class that could query for attachments that are related to email/task records and any other logic to filter attachments you want such as an email subject. Then delete them. And schedule Apex class to run once a day, for example.
- Another workaround to avoid attachments in Salesforce would be to send the generated document as a link to google doc within email (which end user can then export to a PDF format if needed). That way you are not using attachments at all and don’t need to worry about deleting them.