How Do I Add Attachments to an Email?
    • 21 Jun 2024
    • 1 Minute to read
    • Contributors
    • PDF

    How Do I Add Attachments to an Email?

    • PDF

    Article summary

    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, such as XML, PDF, Word, etc.

    Users can retrieve attachments via file access in JavaScript, the Database module, or the 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' attachments will contain what has been included in the MailAttachment JobInfos.

    JobInfo

    Description

    Example

    MailAttachment[index]

    Binary Data

    [Binary]

    MailAttachmentFilename[index]

    Name of file

    test.PDF, test.doc

    MailAttachmentMimetype[index]

    Mimetype for file content

    application/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.

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

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

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

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

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

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

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

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

    1. 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.

    Mail-with-extra-attachments
    55.91 KB