1.877.833.1202

Automating Sending Emails into FileHold

Emails can be added to the DMS using the Microsoft Office Outlook integration either manually or using a watched Outlook folder. However, there may be circumstances where email should be added to the repository without any user or client intervention. This sort of configuration can be handled very simply using off-the-shelf tools in conjunction with FileHold.

One example of where it would be good to add email directly to the DMS is for invoice processing. Your vendors send your invoices to a special email address you provide them such as invoices@company.com. You would like each email to this address to be placed in the DMS for processing by your accounts payable team according to a predetermined workflow.

This example is provided to illustrate the sort of solutions that are possible using the DMS. Support for this example is not included in your FileCare agreement. Ensure you engage fully qualified IT personnel if you would like to setup a similar solution. FileHold professional services can help with this sort of configuration.

Solution Overview

This solution was created on Windows Server 2008R2 Standard with FileHold 14 and using the command line POP3 client from http://www.codeode.com/. A custom script was created (attached) using Windows scripting. The attachments are extracted from the email messages using the MIME unpack utility from http://sourceforge.net/projects/mpack-win/. The Windows Task Scheduler was used to execute the script at regular intervals. FileHold Automatic Document Importation was used to import the email messages and auto workflow initiation was used to begin the payables processing.

The example assumes a workflow called Process Invoices has already been defined for a document schema called Invoice with the appropriate metadata fields. It also assumes the mailbox invoices@company.com has been setup and is ready for the POP3 client to connect. The invoices are expected to be attachments to the email.

Automatic importation of email overview diagram

Setting Up the POP3 Client

The POP3 client requires minimal installation. It is just a matter of copying the executable and configuration file to the desired folder. The configuration file is XML and self-explanatory. We retrieve messages from the server using a simple command line.

popclient –configfile invoicesPOP3.xml

The output is typical text email headers and MIME data. Generally these files have the extension EML, but popclient uses TXT. There is an option for popclient to extract the attachments, but it does not preserve the original filenames, which is desirable in our application. Instead, we will use munpack. Like popclient, this is a simple executable with no installer.

munpack received\*.txt

Running the Script

The entire process of getting the email message from the POP3 server and extracting the attachments is controlled by a simple Windows script (attached). The script can be run from the command line or as a scheduled task. While munpack will ensure the filenames are unique within the temporary directory, we must ensure they are unique across the entire import job. The script will add the date and time to the filename.

The Windows script performs five functions: get new emails, extracts the attachments, gives them a unique name, moves them to the FileHold watched folder (4FileHold), and backs up the original emails. It can be run from the command line or from the Windows task scheduler. All of its messages are written to a log file as the assumption is that it will typically run from the task scheduler.

ProcessMail.cmd

In order to avoid coordinating multiple files, the script will automatically create and delete the configuration file for popclient. The configuration of the Windows task is fairly simple as there are no command line parameters for the script. Depending on where you have installed popclient and munpack, you may want to set the start folder. For the example I have set the script to run every 15 minutes, but you can set any interval.

Automatic importation of emails scheduled task

Setting up Automatic Document Importation (ADI)

ADI is also called server side import. It is an optional feature of FileHold that allows for unattended document imports to be setup and controlled. You can determine if this feature is installed from your system administration screen. You can add this feature at any time by contacting sales@filehold.com. If you do not have this feature you may use the watch folder feature of the FileHold Desktop Application (FDA). This feature is included with every FileHold system. It runs on a client workstation instead of the server. Configuring this solution is not described further in this article.

ADI is configured from the library administration menu. We will need to create an import job to watch for new invoices to be added. A special user called Invoice Automation has been created. This user has only enough rights to perform this specific job. Giving this job a unique user will ensure good information about the source of the documents in the usage log. The documents will be placed in an invoice folder in the accounting cabinet. The document type Invoice will be automatically applied to the documents as they are added.

Automatic imporation of email - ADI job


As new documents are imported they can be viewed in the job details.

Automatic email importation - ADI job details

When the Invoice schema is properly configured to automatically start the Process Invoice workflow, a workflow will be initiated and the approval parties will be notified by email and their task list that they need to approve the invoice.

Automatic email imporation - workflow settings

The POP3 protocol was chosen for this example as it works easily with most existing email infrastructure, but other configurations are possible. For example, an SMTP server is included with Windows server and email could be sent directly to the server rather than going to an external mailbox.