Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Intermediate save

...

Display feature availability
StartingFromRelease1.12.5

Table of Contents

Introduction

This job allows e-mails and their attachments arriving at an in-box to be automatically processed and to be used a basis for generating orders for further Job Chains. In addition, this job can also be used as a pre-processor for other automated mail and atachment processing.  

E-mail Processing Job

This Job is to carry carries out the following:

1. Process attachments

...

  1. Polls an e-mail

...

  1. inbox:
    • Polling is not recursive - sub-folders of the inbox are not polled.
    • Only unread e-mails

...

    • are noted.
    • All e-mails processed are marked as being read.
  1. Writes e-mails found to files:
    • E-mails are marked as read (this cannot be changed).
    • E-mails are written as files to a directory.
      • Parameters:
        • copyMail2File=true
        • directory name
  2. Processes any e-mail attachments:
    • When an e-mail with an attachment is found:
      • The attachment is moved to a directory:

    ...

          • Parameters:
            • copyAttachmentsToFile=true
            • directory name
        • This directory can also be monitored with, for example, a File Order Source

    2. Write e-mails to files

    An e-mail 'incoming basket' is to be polled. Only unread mails will be processed.

    When an e-mail is found:

    ...

    • parameters
      • copyMail2File=true
      • directory name

    ...

    1. Generates an Order for another Job Chain (optional)
      • Parameters:
        • createOrder=true
        • the job chain name

    ...

      • Order parameters:
        • the file name
        • the subject of the mail
        • the sender
        • the mail received date
    1. The mail is

    ...

    1. post-processed (optional):
      • Prameters:
        • afterProcessEmail:
          • markAsRead
            • Default setting
          • delete
            • The mail is deleted
          • move
            • the mail is moved to another folder

      ...

                • Parameter:
                  • the folder name

      ...

      Example Job

      Code Block
      titleExample Job
      languagexml
      collapsetrue
      <job  title="Process email incoming box" order="no" name="ProcessMail">
      
          <description >
              <include  file="jobs/SOSMailProcessInbox.xml"/>
          </description>
      
          <params >
              <param  name="mail_host" value="mail.sos-berlin.com"/>
              <param  name="mail_port" value="993"/>
              <param  name="mail_user" value="myUser"/>
              <param  name="mail_password" value="********Ü"/>
              <param  name="mail_ssl" value="true"/>
              <param  name="mail_server_timeout" value="30000"/>
              <param  name="mail_subject_filter" value="string2search"/>
              <param  name="copy_mail_to_file" value="true"/>
              <param  name="mail_dump_dir" value="c:/temp/mails"/>
              <param  name="process_attachments" value="true"/>
              <param  name="attachement_directory_name" value="c:/temp/attachment"/>
              <param  name="max_mails_to_process" value="20000"/>
              <param  name="after_process_email" value="copy"/>
              <param  name="after_process_email_directory_name" value="email:INBOX/test"/>
              <param  name="mail_server_type" value="IMAP"/>
              <param  name="attachment_file_name_pattern" value="\${subject}_\${filename}"/>
         </params>
      
          <script  language="java" java_class="com.sos.jitl.mailprocessor.SOSMailProcessInboxJSAdapterClass"/>
      
          <run_time />
      </job>

      Provision of E-mails as JavaScript Objects

      JavaScript can be used to retrieve an e-mail as a JavaScript object once the mail has been saved as a file by the SOSMailProcessInBox job. The individual parts of the mail can then further automatically processed as required.

      SOSEmailObject email = getEmailObject(var filename) -

      • String email.getSubject()
      • String email.getAttachmentFilename
      • String email.getReceipient
      • String email.getBody()
      • String email.getReturnAddress
      • String email.get
      • ....

      Example Job Retrieving E-Mail Message

      Here is an example job which retrieves an e-mail message file as a JavaScript object and logs individual properties of the message.

      Code Block
      titleExample Job
      languagexml
      collapsetrue
      <job  enabled="yes" stop_on_error="no">
          <script  language="java:javascript">
              <![CDATA[
      function spooler_process(){
      
      var message = com.sos.jitl.mailprocessor.SOSFileToMailProcessor.getMessage("C:/temp/mails/10f7-5b35e680-71-456fb280@195509842");
      spooler_log.info("Subject: " + message.getSubject());
      spooler_log.info(message.getPlainTextBody());
      spooler_log.info("To:" + message.getFirstToRecipient());
      spooler_log.info("To:" +message.getToRecipient(0));
      spooler_log.info("To:" +message.getRecipient("TO", 0));
      spooler_log.info("CC:" + message.getFirstCCRecipient());
      spooler_log.info("BCC:" + message.getFirstBCCRecipient());
      spooler_log.info("From Address:" + message.getFromAddress());
      spooler_log.info("From Name:" + message.getFromName());
      spooler_log.info("Content-Type:" + message.getHeaderValue("content-type"));
      spooler_log.info("Message Id: " + message.getMessageId());
      spooler_log.info("Date:" + message.getSentDate().toLocaleString());
      spooler_log.info("Attachment Count:" + message.getSosMailAttachmentsCount());
      spooler_log.info(message.getSosMailAttachments().get(0).getContentType());
      	return false;
      }
              ]]>
          </script>
          <run_time />
      </job>

      ...