Create email with attached System.FileDocument

My app is generating invoice-documents as pdf. These documents are stored as System.FileDocument. Now I like to have a microflow, which creates an email including the pdf-document as attachment. I succeeded to create and send the email-message. However, how do I attach the pdf-document to the email; in other words: how do I create the System.FileDocument which is related to the Email and fill it with the System.FileDocument-data which are related to my invoice ?
2 answers

If you are using the email module out of the appstore, you have to create a an Attachment document, which is part of the module, relate is to the email and you can use the CopyAttachmentContent function from the community commons module to copy your invoice the the new FileDocument.


Create an object EmailTemplate.Attachment, copy the pdf into that (java-action  DuplicateFileDocument) and link it to the mail object you created.


If you don't like the objects to be duplicated create an assocation from pdfdocument to email and change the mf IVK_SendMail to retrieve the pdfs directly