Mail Configuration (incoming)

Incoming emails can be efficiently processed using SIL scripting, providing an unparalleled level of flexibility. Review the following video for an overview of this feature.

https://fast.wistia.com/embed/medias/1zu9iz5vix.jsonp

To set up an incoming mail configuration, navigate to the Integrations → Incoming Mail page in the Power Apps Config page.

image-20240527-090607.png

Clicking on the Add configuration allows you to set up a single (for now) Incoming mail configuration. This configuration will process incoming emails and execute the designated SIL script.

Parameters

The required fields for setup are as follows:

  • Protocol
    The selected value must correspond to the enabled protocol on the mail server. Currently, POP3 and IMAP are supported.

  • Mail Host
    This should contain the server’s hostname or its IP address (e.g. imap.gmail.com)

  • Port
    This indicates the port on which the server is listening. It is pre-filled with the default value of the port for the selected Protocol.

  • User Mailbox

    Please enter the account username to which you want this configuration to connect (e.g. testincomingemail@gmail.com).

  • Password
    This contains the password that will be used to set up the connection. It is not the actual mail password but, for Gmail, for example, it is the generated App password.

  • Script
    Choose the SIL script that you wish to run each time a new incoming email is captured. Make use of the purpose-built Incoming Mail Processing Functions available within the SIL script to achieve your processing objectives.

  • Mail check interval
    Set the frequency in minutes for checking new messages in your mailbox.

  • Maximum message size
    To prevent processing failures resulting from out-of-memory errors, it's important to set a maximum file size limit in megabytes. Any emails exceeding the limit will not undergo processing.

  • Delete processed emails
    Enable this toggle to instruct the mail server to delete the emails once they are processed.

Make sure you test the connection before you save it!

Once saved, a correctly set up Incoming mail configuration will appear as follows:

image-20240527-102854.png

Notice the processing status. Every time the configured interval is reached, a new call is made to the mail server and the new emails are processed.

The operations supported here are: pausing the processing, testing, editing, or deleting the configuration.

If you opt to pause the process, it will transition to disabled, and you can resume it later. If any of the provided details change and the configuration becomes invalid, the status will switch to DISCONNECTED, requiring you to make edits to make it return to the processing state.

The processing results will be displayed in the Processing history table below, which retains the latest 10 outcomes.

Script example

Here is a sample script that can be used in an Incoming mail configuration to create a new issue every time a new email is received, meeting the following specifications:

  • the subject of the email contains the name of a project;

  • the body of the email will serve as the new issue’s description;

  • the reporter of the newly created issue will be the extracted from the email’s From field;

  • the watchers for the newly created issue will be extracted from the email’s CC.

IncomingEmail mail = getIncomingEmail(); string issueKey = mail.subject; if(issueExists(issueKey)) { // add comment string commentText = mail.body; string userCommenting = getUserByEmail(mail.from).key; addComment(issueKey, userCommenting, commentText); attachAllFilesFromEmail(issueKey); } else { // create issue string summary = mail.subject; string description = mail.body; string [] fields = {}; fields += {"reporter", getUserByEmail(mail.from).key}; createIssue("PROJECT NAME", "", "Task", summary , "Minor", description, {}, "", "", fields); }

For more information regarding the IncomingEmail SIL structure and other useful email functions, visit this page: https://appfire.atlassian.net/wiki/spaces/PSJC/pages/999162356/Incoming+Mail+Processing+Functions#IncomingMail

 

Peacock