MSGraph Mail Poller

Overview

Need to poll emails from your Exchange server? This smart service can be used in a poller process and extract the data from the Microsoft Exchange server. Messages are stored in the Appian Document System, as well as the attachments. Meta data is stored in a database table for further processing.

This plug-in provides an alternative to sending emails to an Appian process model when inbound email integration is requested. Instead of the email being forwarded to Appian, this plug-in reads the emails directly from the Exchange mailbox using the MS Graph API as described below:

  • Reads the mailbox(including digitally signed emails) using the MS Graph API
  • Convert the email to an EML file stored as an Appian document, with attachments removed from it
  • Store all email attachments as separate Appian documents
  • Store all email metadata (subject, author, recipients, etc...) into a set of tables in the database

Key Features & Functionality

  • All information how to deploy, configure and use the smart service is in the 'MS Graph Mail Poller.pdf' document in the downloaded zip.
  • Extract the files in the ZIP and follow the instructions in the document.
  • This plugin currently supports only MySQL and Oracle databases.
Anonymous
  • Check your stdOut log but likely your DB structure is old and you need to update the structure to match the latest scripts.

  • Hello. We just upgraded the plugin to v4.4.0 and we also upgraded to Appian 25.4.  When running the poller, it cannot write to the database.  I did not update the node in the process.  It still points to jdbc/Appian just as it did before the latest version.  Any ideas?

  • v4.4.0 Release Notes

    • Now supporting simultaneous polling for up to five distinct mailboxes.
  • Thanks for flagging this, the improvement suggestion also seems reasonable.

  • Empty Document Names for Email Attachments Without Subject

    Problem Description:

    When processing emails with attachments that have no name or subject (e.g., draft emails without a subject line attached to another email), the MS Graph Mail Poller plugin would import in appian the attachment documents with empty names. This is incoherent with out of the box Smart Service Edit Document Properties that does not allow to edit a document with an empty name.

    Scenario to Reproduce:

    • Create a draft email without a subject
    • Drag and drop that draft email as an attachment to another email
    • Send the email to a mailbox monitored by the plugin
    • The plugin will create a document with an empty name

    Suggestion of improvement:

    Attachments without names should be stored with sequential naming (`Untitled_1`, `Untitled_2`, etc.), preventing NullPointerException and empty document names in Appian. Logic to be applied to both regular and digitally signed (S/MIME) email processing paths.
  • Dear Team, we have a requirement to read only specific emails from mailbox, currently we couldn't find any option to configure target folder to read emails from. It'll be very helpful if we could do that in future versions.

  • v4.3.3 Release Notes

    • Updated rules for table names and vulnerabilities.
  • Performance Optimization Tip: Reduce Graph API Payload When Generating EML Files

    Context: When generating EML files without file attachments, we can avoid retrieving unnecessary attachment data from Microsoft Graph API.

    Location: In the extractDataAndDocFromMimeContentProxied method, when processing the EML generation path that excludes file attachments.

    Recommended Change:

    Use selective field retrieval with .select("id"):

    AttachmentCollectionPage attachments = mc.graphClient.users(mailbox)
        .messages(copyMsg.id)
        .attachments()
        .buildRequest(requestOptions)
        .select("id")
        .get();

    Instead of retrieving all fields:

    AttachmentCollectionPage attachments = mc.graphClient.users(mailbox)
        .messages(copyMsg.id)
        .attachments()
        .buildRequest(requestOptions)
        .get();

    Benefits:

    • Reduced network transfer: Avoids downloading large contentBytes from each attachment
    • Faster API response: Graph API returns only attachment IDs instead of full attachment data
    • Lower memory usage: Especially beneficial for messages with multiple large attachments
    • Same functionality: Attachment IDs are sufficient for deletion operations

    Performance Impact: For messages with large attachments (e.g., 5+ files totaling 50+ MB), this can reduce API response time by 50-70% during EML generation without attachments.

    This optimization applies specifically when generating EML files where file attachments are excluded (isKeepFileAttachmentsInEml != INCLUDE).

    Hope this helps optimize your Graph API integrations!

    Best regards,
    NLC

  • Is your DB in the right utf8 collation?

  • Bearer Token Not Being Passed in Proxied Requests to Microsoft Graph API

    Issue Description:
    When using the MS Graph Mail Poller plugin (version 4.3.2) with proxy authentication enabled (isConnectedViaProxy = true), requests to Microsoft Graph API fail with HTTP 401 Unauthorized errors. The Bearer access token is not being included in the API requests.

    Root Cause:
    In the MSGraphConnector.java file, the OkHttpClient (serviceHttpClient) is being built at line 73 BEFORE the TokenCredentialAuthProvider is created at line 97-99. This means the HTTP client is constructed without any mechanism to attach authentication tokens to outgoing requests. Even though the TokenCredentialAuthProvider is later passed to the GraphServiceClient builder, the underlying HTTP client was already finalized without token support, so it never adds the Bearer token to requests.

    Suggested Fix:
    The code in the isConnectedViaProxy block needs to be restructured:

    1. Remove the early serviceHttpClient build (lines 67-73)
    2. Create the TokenCredentialAuthProvider first (before building the HTTP client)
    3. Use HttpClients.createDefault(tokenCredentialAuthProvider).newBuilder() to initialize the HTTP client builder - this ensures tokens are automatically included
    4. Add proxy settings, timeouts, and proxy authenticator to the builder
    5. Build the serviceHttpClient as the LAST step after all configuration is complete

    The key is using HttpClients.createDefault(tokenCredentialAuthProvider) which creates an OkHttpClient.Builder that's pre-configured to inject Bearer tokens into all requests. The current code bypasses this by creating a plain OkHttpClient.Builder without the token provider.

    Impact:
    Without this fix, proxy-authenticated environments cannot retrieve emails. With the fix, Bearer tokens are properly included and authentication succeeds.