> For the complete documentation index, see [llms.txt](https://docs.alemba.com/asm-eos-10.5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.alemba.com/asm-eos-10.5/setup-and-configure-asm/setting-up-your-system/setup-email/setting-up-incoming-and-outgoing-email/incoming-email-via-api.md).

# Incoming Email via API

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

![](/files/qaQPm3QlJsjwI5ji00bD)

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.

   <figure><img src="/files/1WeApD1ogAAKViD1b4WC" alt=""><figcaption></figcaption></figure>
2. Add an “Initialize variable” action where the variable name is Attachments and the type is array:&#x20;

   <figure><img src="/files/W1PfV5aJDPWdsz4msdta" alt=""><figcaption></figcaption></figure>
3. Add an “Initialize variable” action where the variable name is BodyHtml and the type is string:&#x20;

   <figure><img src="/files/7DihzpAFhWyAnF1EabjT" alt=""><figcaption></figcaption></figure>
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:&#x20;

   <figure><img src="/files/kXzZPxCrKBYViiNo0akP" alt=""><figcaption></figcaption></figure>
5. Add a “Condition” action within the “for each” action that will check whether the Attachments Is Inline value is equal to true:&#x20;

   <figure><img src="/files/0ldUhVoKeqVHA4XZj8X9" alt=""><figcaption></figcaption></figure>
6. Go into the settings of the “for each” action and set the concurrency control limit to 1:&#x20;

   <figure><img src="/files/W6Xkd7FMT3jjr7KEgxL7" alt=""><figcaption></figcaption></figure>
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.&#x20;
     * 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’.&#x20;
     * When creating the function app, ensure that the Runtime stack is set to ‘Node.js’ and the Version is set to ’12 LTS’.&#x20;
     * 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.&#x20;
     * Extract this zip file and open it up in VS Code.  &#x20;

       <figure><img src="/files/R2Gxuta1F4vTyOUaWv3Z" alt=""><figcaption></figcaption></figure>
     * In the explorer right click on ReplaceInlineImages and select ‘Deploy to Function App…’.&#x20;
     * Select the relevant subscription .     &#x20;

       <figure><img src="/files/jFUosEZgxEc7ENhKYPsg" alt=""><figcaption></figcaption></figure>
     * Select the relevant function app. &#x20;

       <figure><img src="/files/XxGEBCs1FHSJuCJAi2HN" alt=""><figcaption></figcaption></figure>
     * Then click deploy. &#x20;

       <figure><img src="/files/DGW8epvTw8DFRxFqqcP0" alt=""><figcaption></figcaption></figure>
     * 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.&#x20;
   * Parse the ReplaceInlineImages Json Response
   * Set the BodyHtml variable with the DescriptionHtml

![](/files/yc4gQFcQJ9p73QF82ePS)

## 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.

![](/files/4YCxpg464Hlgwu4ItShm)

![](/files/itDdBis6IiRBm700nUJX)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.alemba.com/asm-eos-10.5/setup-and-configure-asm/setting-up-your-system/setup-email/setting-up-incoming-and-outgoing-email/incoming-email-via-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
