Incoming Email via API

Email Configuration – Incoming Alemba API

New for 10.5, a new “Alemba API” protocol is available to select when creating a new incoming email server:

A new field called “Email Server Id” will appear which will contain a value. This value is needed when creating requests to add emails via the API.

The remailing fields are the standard incoming email fields.

Logic App Configuration

  1. Create Logic App with the “When a new email arrives (V3)” Office 365 Outlook trigger. The “Include Attachments” parameters needs to be enabled.

  2. Add an “Initialize variable” action where the variable name is Attachments and the type is array:

  3. Add an “Initialize variable” action where the variable name is BodyHtml and the type is string:

  4. Add a “For each” action which will loop through the Attachments from the trigger and will append the Attachments Content, Attachments Name and Attachments Is Inline values to the attachments array:

  5. Add a “Condition” action within the “for each” action that will check whether the Attachments Is Inline value is equal to true:

  6. Go into the settings of the “for each” action and set the concurrency control limit to 1:

  7. Under the “True” side of the condition add the following actions:

    • Link to the ReplaceInlineImages Azure function

      • This action will pass the attachment name, ref and the HTML version of the description to the ReplaceInlineImages functions and will return the updated HTML version of the description, to include the inline image.

      • Before adding this action, you will need to create a function app and the function itself. An example of this function app can be found in the INFORMCOMMS directory, under the name ‘email-func-inline-attachments-scottd’.

      • When creating the function app, ensure that the Runtime stack is set to ‘Node.js’ and the Version is set to ’12 LTS’.

      • The function needs to be deployed locally using VS Code. You can find details about doing this if you go to functions and click on Add. Select VS Code as the Development environment. It will give instructions on how to configure VS Code to deploy to Azure Functions.

      • Extract this zip file and open it up in VS Code.

      • In the explorer right click on ReplaceInlineImages and select ‘Deploy to Function App…’.

      • Select the relevant subscription .

      • Select the relevant function app.

      • Then click deploy.

      • Once completed you can see if it was successful by accessing the function app and see if the ReplaceInlineImages function exists. It will not let you see or modify the code within the Azure Portal, so if any modifications are needed, they will need to be done in VS Code and redeployed.

    • Parse the ReplaceInlineImages Json Response

    • Set the BodyHtml variable with the DescriptionHtml

Post to the Alemba API

  1. Outside of the “for each” loop add a new “Http” action that will post the data to the Alemba API. You will need to add any necessary authentication. The endpoint url will follow this format: https://{Server Endpoint}/{System Name}/alemba.api/api/v2/email-incoming/ . The “EmailServerId" parameter is the “Email Server Id” value from the email server settings in ASM.