Internet Mail Archive System

From PresenceWiki
Revision as of 10:17, 28 February 2012 by Graham (Talk | contribs)

Jump to: navigation, search
Tutorial Pages > Internet Mail Archive System

Overview

This document describes the IMAS system and how it was created using Presence.

The IMAS System currently performs 3 functions:-

  • The Mail Service connects to a POP(email) account and downloads attachments, based on conditions defined under the rules menu.

It places each attachment in a separate folder in .\res\httpdocs\imas\scan\BasicDetach

  • The Rule Service will then process each of these directories by copying each attachment to a Network or AS400 location, or by running run a task that will access the file through the variable ${localfile}.
  • The Task Service will also run extra user defined tasks if neccesary.

Presence Tasks

Queued Processes

Queue Scan POP
Queue Rule Action

On-Demand Processes

OnDemand MainPage (alias imas.mainPage)

General IMAS Solution

Here we will take a look at the general IMAS solution and show how it can Scan attachments from emails and upload them to either an AS400 Folder a Network Folder or run a task with them.

The first screen here is the IMAS config screen. IMAS is located in the Presence res/httpdocs directory, so with the both the Presence HTTP Server and the IMAS tasks running, we can go to:-

http://localhost/imas

The first screen we will see is the IMAS config screen.

http://www.international-presence.com/images/imas/editconfig.png

Here we can define an administrator email, who will get notified of any of exceptions that occur.

As each attachment is processed, the name of the folder that gets created is incremented. We can also see the next folder number as well as define the name of the folder that failed attachments end up in.

Under the AS400 screen we can add and edit AS400 connections.

http://www.international-presence.com/images/imas/editas400.png

Similarly the Email screen allows us to configure which POP accounts we need to be read.

http://www.international-presence.com/images/imas/editemail.png

The rule screen lets us define what happens when we query a pop account.

Each rule is associated with one email account as defined in the previous tabs.

The action to perform can be one of:-

  • Upload To Network Folder
  • Upload To An AS400 (as defined in the AS400 menu)
  • Run A Task

Below the action type, we specify the Task or Network/AS400 folder.

The From Address, allows us to only process emails from a specific address (leave brank to process all the emails in this account).

In Attachment we can specify to only process emails that have a certain type of attachment.

In Filename we can specify to only process emails that have a certain filename match.

Subject allows us to only process emails that match this subject.

Convert XLS to CSV will convert any XLS attachments to CSV attachments.

http://www.international-presence.com/images/imas/editrule.png

The IMAS system works on a file scan basis, so that the 3 separate processes create and process folders in the IMAS directory.

http://www.international-presence.com/images/imas/basicdetach.png

Note there are 2 files in each folder as one is the trigger folder (imasready).

This Task can be stopped and started using the Mail Service Screen and the logs will describe what is happening.

http://www.international-presence.com/images/imas/mailservice.png

We then need to run the rule service, this will perform the required action on each of the folders created from the Mail Service.

We can find a list of any emails that where unable to be processed in the Email Exceptions Page:-

http://www.international-presence.com/images/imas/mailexceptions.png

From here we can email ourselves a copy of the report.

We can find a list of Rules that failed to run in the Rule Exceptions Pages

http://www.international-presence.com/images/imas/ruleexceptions.png

From here we can email ourselves a copy of the report.

Adding A Custom Task To The Solution

Here, we will study the solution delivered to DAS to give us an overview of the capabilities and operation of IMAS.

The requirement for DAS was to scan an email account for files that can be one of four types:-

  • HomeFixed
  • HomeDelimitted
  • MotorFixed
  • MoterDelimitted

Attachments, can also come through as zipped, in which case we needed to get Presence to unzip them so that it can then treat them as standard attachments.


As an example we will send 1 email that contains a zip file containing one of each file (HomeFixed,HomeDelimitted MotorFixed,MoterDelimitted) as well as an individual file MotorDelimitted.txt and another file Wrong.txt which contains invalid data.

When the Mailservice runs each of these files will be detached and placed in:-

res\imas\scan\basicdetach folder, in a separate folder each:-


In this case it will run the task "Move Folder Into Bucket". This task actually opens each file and decides whether it is:-

The Custom Tasks need to be added to the table imas.customtasks, nodes for this can be found in the Instructions task

http://www.international-presence.com/images/imas/buckets.png

Select * from imas.customtasks

http://www.international-presence.com/images/imas/customtasksselect.png

  • HomeFixed
  • HomeDelimitted
  • MotorFixed
  • MoterDelimitted

And places it in the corresponding scan directory. If it can't decide it places it in the Unknown directory:-

All this can be seen on the Rule Service Screen, where again we can view the logs and stop and start this service.

http://www.international-presence.com/images/imas/ruleservice.png

We have added a Custom Task to process each bucket directory. This is an extension to the IMAS system which allows for extra tasks, to be added as services. This task is "Process Bucket Directories"

For each type of directory, it will populate a table on the as400 (from the file), and then run a program call on the as400, after which the file will be deleted. To run this Custom Task, we need to go to the task service, select it from the combo, then hit start.

http://www.international-presence.com/images/imas/taskservice.png


http://www.international-presence.com/images/imas/taskexceptions.png