FEATURE AVAILABILITY STARTING FROM RELEASE 1.12.5
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 attachment processing.
E-mail Processing Job
This Job carries out the following:
- Access an e-mail inbox:
- Polling is not recursive - sub-folders of the inbox are not polled.
- Access parameters
Parameter Comment Options Default Example mail_host imap@testLand.com mail_port 110 mail_user demo.user@testLand.com mail_password stored as plain text mail_ssl mail_server_type IMAP, POP3 POP3 mail_server_timeout milliseconds 0 (no timeout)
- Filter e-mails for matches:
- Only unread e-mails are considered.
- All e-mails matched are marked as being read.
- Filter parameters:
Parameter Comment Options Default Example mail_message_folder csv INBOX mail_subject_filter matches string string - TestMail_01 mail_subject_pattern matches regex - TestMail_\d\d mail_body_pattern matches regex min_age 0, secs, hrs:mins, hrs:mins:secs mail_use_seen true, false true
- Carry out one or more actions one after the other:
- Possible actions are:
Parameter Comment Options Default Example mail_action csv dump, 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).
- Possible actions are:
- Save the e-mails found to files when the mail_action parameter is set to dump:
- E-mails found are written as files to a directory.
Parameters:
Parameter Comment Options Default Example copy_mail_to_file alternative to mail_action = dump true, false true mail_directory_name D:\_AA\_demo\mails max_mails_to_process 200000
- E-mails found are written as files to a directory.
- Process any e-mail attachments:
- When an e-mail with an attachment is found:
- The attachment is moved to a directory:
- Parameters:
Parameter Comment Options Default Example copy_attachments_to_file alternative to mail_action = copy_attachments_to_file true, false false attachment_file_name_pattern \${subject}, \${filename}, \${messageId} \${subject}_\${filename} attachment_directory_name requires: mail_action or copy_attachments_to_file D:\_AA\_demo\mails
- Parameters:
- This directory can also be monitored with, for example, a File Order Source
- The attachment is moved to a directory:
- When an e-mail with an attachment is found:
- Generate an Order for another Job Chain:
- Parameters:
Parameter Comment Options Default Example create_order alternative to mail_action = order true, false false 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
- the file name
- the subject of the mail
- the sender
- the mail received date
- Parameters:
- Post-process the mail (optional):
Parameters:
Parameter Comment Options Default Example after_process_email markAsRead, delete, move,copy markAsRead after_process_email_directory_name email:INBOX/subfolder_in
Example 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.
The ...