The system determines the type of email based on the keyword in the email subject that you configure. Once the email type is determined, the system checks the attachment file names to determine the type of attachment and the method for processing the attachment.
In MailAttachmentBot Manager, click the "Mail Type Config" icon to open the mail type list.
In this list, click the "Add Mail Type" button to open the "Edit Mail Type Config" dialog box.
Edit Mail Type Config dialog box
In this dialog box:
Mail Type Name |
Enter the name of the email type. The mail type name must be unique. |
Keyword in Subject |
Enter the keyword that will appear in the subject of this type of email, case-insensitive. When an incoming email contains this keyword in the subject, the system will classify the email as this type and process it accordingly. The keyword format adheres to the wildcard syntax of PostgreSQL’s LIKE statement (e.g., '%' for any string, '_' for a single character). For example: If the keyword is "%abc%" and the email subject contains "abc", it will be classified as this type of email. If the keyword is "abc%" and the email subject starts with "abc", it will be classified as this type of email. For more information about the LIKE statement in PostgreSQL, please visit https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE |
Allowed Senders |
Set the addresses that are allowed to send emails of this type. After determining the email type, the system checks whether the sender's address is in the Allowed Senders list. Only emails sent from addresses listed in Allowed Senders will be processed. You can set multiple email addresses in Allowed Senders. |
Allow anyone to send this type of email |
If you select this option, emails of this type from all addresses will be processed. Otherwise, only emails from addresses in the Allowed Senders list will be processed. |
Run Task Before Starting Email Processing |
You can enter a task name here, and the system will execute this task before processing emails of this type. If the task fails, the system will abort the processing. In this task, you can use your own criteria to inspect the email, such as checking if the sender has included duplicate attachments. The task being called must be of the type "HTML Email" or "Text Email". The task's status must be set to "Enabled". When the system executes the task you have set, it will pass the MailUUID and the email type to your task. Therefore, your task must include variables named MailUUID and MailType, and you must check the option "Allow passing variable value from external interface table or @@RunTask function" on the variable options page for both variables. You can use the passed MailUUID in your task to query the detailed information of the email to be processed in the v_inbox_mail view. |
Run Task on Email Processing Success |
You can enter a task name here. When email processing succeeds, the system will execute this task. You can perform operations within this task, such as processing imported data or notifying the sender of the email's processing outcome. By default, the system executes the "SendEmailProcessingSuccessNotification" task to inform the sender that the email has been successfully processed. The task being called must be of the type "HTML Email" or "Text Email". The task's status must be set to "Enabled". When the system executes the task you have set, it will pass the MailUUID and the email type to your task. Therefore, your task must include variables named MailUUID and MailType, and you must check the option "Allow passing variable value from external interface table or @@RunTask function" on the variable options page for both variables. You can use the passed MailUUID in your task to query the detailed information of the email to be processed in the v_inbox_mail view. If "Run Task on Email Processing Success" is empty, the system will not start any additional tasks when email processing succeeds. |
Run Task on Email Processing Failure |
You can enter a task name here. When email processing succeeds, the system will execute this task. You can perform operations within this task, such as processing imported data or notifying the sender of the email's processing outcome. By default, the system executes the "SendEmailProcessingSuccessNotification" task to inform the sender that the email has been successfully processed. The task being called must be of the type "HTML Email" or "Text Email". The task's status must be set to "Enabled". When the system executes the task you have set, it will pass the MailUUID and the email type to your task. Therefore, your task must include variables named MailUUID and MailType, and you must check the option "Allow passing variable value from external interface table or @@RunTask function" on the variable options page for both variables. You can use the passed MailUUID in your task to query the detailed information of the email to be processed in the v_inbox_mail view. If "Run Task on Email Processing Success" is empty, the system will not start any additional tasks when email processing succeeds. |
Related File Types |
You can set which file types are included in this email type. During email processing, the system first determines the email type based on the subject keyword, then checks the attachment names using the keyword in the Related File Types configuration to determine the type of attachment and how to process it. |
Configuring the Relationship Between Mail Types and File Types
You need to set the list of related file types for each mail type in the Mail Type Config. During email processing, the system first determines the email type based on the subject keyword. Then, it checks the attachment names according to the keyword configured in the Related File Types to determine the file type of the attachment.
When matching file name keyword, the system will prioritize records that appear earlier in the list. To adjust the priority order, select the record you want to move and click the "Move Up" or "Move Down" button.
To add a record, click the "Add Related File Type" button, and the system will open the "Edit Mail Type Related File Type" dialog.
In this dialog box:
Related File Type |
Select the file types to be added to this mail type. |
Keyword in File Name |
Enter the keyword for the attachment file name. The system determines the attachment type by searching for this keyword in the file name and processes it accordingly. The formatting of "Keyword in Subject" follows the PostgreSQL LIKE statement and is case-insensitive. For example: If the keyword is "%aaabbbccc%", and the file name contains "aaabbbccc", it will be classified as this attachment type. If the keyword is "aaabbbccc%", and the file name starts with "aaabbbccc", it will be classified as this attachment type. If "Keyword in Subject" is empty, this relationship will be invalid. For more information about the LIKE statement in PostgreSQL, please visit https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE |
When determining the mail type, the system will match keyword based on the priority order of the mail types. Mail types with higher priority will be matched first. For example, if you have the following mail types:
In this case, if the subject of the received email is "SalesReport," the system will first match "%Sales%" and classify the email as the "SalesData" type, which is not what we expected.
We can resolve this issue by adjusting the priority of the mail types.
Click the "Priority Setting" button, select the "RegionSalesReport" entry, click "Move Up," and then click "OK" to save the priority configuration.
After reprocessing the email, the system will be able to correctly determine the mail type.
Once the mail types are configured, add the email account used for receiving emails in the "Email Accounts Manager." For instructions on configuring the email account, please refer to the Adding an Email Account chapter in the SQLMessenger manual.
Click the "Email Accounts" icon in the MainMenu.
Click the "Add Email Account" button.
When configuring the email account, make sure to check the "Allow SQLMessenger to receive emails" option. Then click "Email Receiving Settings" to open the "Email Receiving Settings" dialog.
Next, click "Select Tasks," choose the "MailAttachmentBot" task in the left list, and add it to the right list, then click "OK."
Once the email account is configured, the system will check the inbox every 30 seconds for new emails. If a new email is found, the "MailAttachmentBot" will be triggered to process the email.