Skip to main content

How to add attachments to an email - Knowledgebase / Lasernet / Lasernet Developer FAQs - Formpipe Support Portal

How to add attachments to an email

Authors list

This article provides a solution for how to include additional attachments in an email.

A standard document generated by Lasernet (stored in JobData) can be emailed via the Mail Output Port.

Also, additional documents can be stored as extra attachments to the standard document(JobData). Both JobData and mail attachments can contain any text or binary format, like XML, PDF, Word, etc.

Users can retrieve attachments via file access in JavaScript, the Database Module or File Retriever Module (file, FTP or HTTP) and insert them as mail attachments via the required JobInfos.

A list of JobInfos must be defined for the Mail Output Module. The first attached file in the email will by default contain the JobData. The remaining files' attachment will contain what has been included in the MailAttachment JobInfos.


JobInfoDescriptionExample
MailAttachment[index]Binary Data[Binary]
MailAttachmentFilename[index]Name of filetest.PDF, test.doc
MailAttachmentMimetype[index]Mimetype for file contentapplication/pdf, application/msword


Example

In the following example, the data file contains references to two extra attachments that we want to pick up during the process and attach to the email as well. Follow these steps:

1. Create a data file with reference to the name of the attachments, in this case only the first part of the filename can be the full name.

2. Open the files folder with the files to pick up.


3. Open the File Retriever modifier, name it GetFiles and then click the Setup tab.

4. Ensure the Replace JobInfo checkbox is cleared to make an array.


5. Open the Script tool and configure the script to read the first part of the name from the data.

6. Run and fetch the FileRetriever and set the names of the files in a JobInfo array of MailAttachmentFileNames.


7. Configure the Form to run the script, thereby picking up the attachments.

8. Create a Pattern for the attachments and a Rearrange on the data field with the name on it to run the script.


9. At this stage, you can test the fetching of files from Developer. To view the files being picked up, click View in the menu bar and select the Logger checkbox.


10. Ensure your standard data output has set the JobInfo Filename. This could have been set dynamically.

Consider having a proper MailRecipient set in JobInfo MailTo (can be set on any module or form). In the attached test setup, you will need to configure Mail Output Port to your settings.


When sending data through you should get something like this:

Use the attachment to this article as test data to test the setup with a grab file inside.

Helpful Unhelpful

Add a comment

Please log in or register to submit a comment.

Need a password reminder?

Share