Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 attachment processing.  

Article Scope

The reference documentation for the  SOSMailProcessInBox Job with detailed parameter descriptions is available online and in the JobScheduler installation ./jobs sub-folder. The current article 

E-mail Processing Job

This Job carries out the following:

  1. Accesses Access an e-mail inbox:
    • Polling is not recursive - sub-folders of the inbox are not polled.
    • Access parameters
      • ParameterCommentOptionsDefaultExample
        mail_host
        -
           imap@testLand.com
        mail_port
        - 993
          110 
        mail_user
        -
           demo.user@testLand.com
        mail_password
        -
        stored as plain text   
        mail_ssl
        - true/false
            
        mail_server_type
        -
         IMAP, POP3POP3 
        mail_server_timeout
        - seconds
        milliseconds 0 (no timeout) 
  2. Filter Filters e-mails for matches:
    • Only unread e-mails are considered.
    • All e-mails processed matched are marked as being read.
    • Filter parameters:
      • ParameterCommentFomatOptionsDefaultExample
        mail_message_foldercsv INBOX 
        mail_subject_filtermatch matches stringstring-TestMail_01
        mail_subject_patternmatches regex -TestMail_\d\d
        mail_body_patternmatches regex   
        min_age 0, secs, hrs:mins, hrs:mins:secs  
        mail_use_seen true, falsetrue 
  3. Carry out one or more actions one after the other:
    • Possible actions are:
      • ParameterCommentOptionsDefaultExample
        mail_actioncsvdump, order, command, delete, copy_attachments_to_file   
      • dump: save the content of the e-mail as a file located in mail_directory_name.
        relevant if copy_mail_to_file = false (default is true).
      • order: an order will be generated for each mail
        relevant if create_order = false.
      • command: the body of the e-mail will be used as a command.
      • delete: the email will be deleted.
      • copy_attachments_to_file:
        relevant if copy_attachments_to_file = false (default value).

  4. Save the e-mails found to files when the mail_action parameter is set to dump:Writes e-mails found to files:
      E-mails found are marked as read (this cannot be changed).
    • E-mails found are written as files to a directory.
      • Parameters:

        ParameterCommentOptionsDefaultExample
        copy_mail_to_filealternative to mail_action = dumptrue, falsetrue 
        mail_directory_name   D:\_AA\_demo\mails
        max_mails_to_process
      • after_process_e
      •   200000 
  5. Process Processes any e-mail attachments:
    • When an e-mail with an attachment is found:
      • The attachment is moved to a directory:
        • Parameters:
          • ParameterCommentOptionsDefaultExample
            copy_attachments_to_filealternative to mail_action = copy_attachments_to_filetrue, falsefalse 
            attachment_file_name_pattern \${subject}, \${filename}, \${messageId}\${subject}_\${filename} 
            attachment_directory_namerequires: mail_action or copy_attachments_to_file  D:\_AA\_demo\mails
      • This directory can also be monitored with, for example, a File Order Source
  6. Generates Generate an Order for another Job Chain (optional):
    • Parameters:
      • createOrder=true
      • the job chain name
      • ParameterCommentOptionsDefaultExample
        create_orderalternative to mail_action = ordertrue, falsefalse 
        mail_jobchain    
        mail_order_id    
        mail_order_title    
        mail_order_state    
    • The following parameters will be generated from the parameters of the original e-mail:
      • "mail_from": sender of mail
      • "mail_from_name"
      • "mail_message_id": message id of mail
      • "mail_subject": the subject
      • "mail_body": the body
      • "mail_send_at": date of sending the mail
      Order parameters:

      • the file name
      • the subject of the mail
      • the sender
      • the mail received date
  7. The mail is post-processed Post-process the mail (optional):
    • Prameters

      Parameters:

      Parameter
      afterProcessEmail:
      Comment
      markAsRead
      OptionsDefault
      setting
    • delete
      • The mail is deleted
    • move
      the
      Example
      after_process_email markAsRead, delete, move,copymarkAsRead 
      after_process_email_directory_name   email:INBOX/subfolder_in
      mail is moved to another folderParameter:
      the folder name

Example Job

Code Block
languagexml
titleExample Job
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>

...