MSGraph Email 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 using the MS Graph API
  • Convert the email to an EML file stored as an Appian document; Item attachments (calendar invites, messages) are kept in the eml file, File attachments removed from it and stored separately in the document management system.
  • Store all email file 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.

Anonymous
Parents
  • Hello, what are the conditions when emails are moved to Exception folder? In some cases emails with big attachments are moved there, in some cases we notice that some short network breakdowns are triggering exceptions. What would be recommended way to handle those exceptions?

  • Do you mean from the Appian process side? Or the plugin? The plugin can't process these emails for various reasons so they won't make it into Appian as-is. It's really up to you what you want to do here - since the plugin returns the number of emails with errors, at a basic level, you can send an email to an admin to investigate. You can get more sophisticated with some automatic probing of the emails by creating integrations into the inbox and presenting data back to the admin.

    In some cases moving the emails back into the inbox will resolve these, but some emails contain corrupt attachments and such and will need to be dealt on a case by case basis.

Comment
  • Do you mean from the Appian process side? Or the plugin? The plugin can't process these emails for various reasons so they won't make it into Appian as-is. It's really up to you what you want to do here - since the plugin returns the number of emails with errors, at a basic level, you can send an email to an admin to investigate. You can get more sophisticated with some automatic probing of the emails by creating integrations into the inbox and presenting data back to the admin.

    In some cases moving the emails back into the inbox will resolve these, but some emails contain corrupt attachments and such and will need to be dealt on a case by case basis.

Children
  • The original issue occurs while copying an attachment, unfortunately, not much we can do about a socket timeout. Then the next problem is when we try to move the message, we get another socket timeout and the exception handling has a defect in it that skips writing to the outputs.

    We will fix the exception handling so at least there will be an error in the node outputs and we will attempt to process additional messages.

    It may be worth reaching out to MS to report an issue with their APIs (especially the second error since it is clear the issue in their method).

  • Hi Mike, here it goes!
    ERROR com.appiancs.msgraphmail.MSGraphMessageHandler - Error during email processing java.net.SocketTimeoutException: timeout at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.kt:675) at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.kt:684) at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.kt:379) at okhttp3.internal.connection.Exchange$ResponseBodySource.read(Exchange.kt:276) at okio.RealBufferedSource.read(RealBufferedSource.kt:192) at okio.RealBufferedSource.exhausted(RealBufferedSource.kt:200) at okio.InflaterSource.refill(InflaterSource.kt:112) at okio.InflaterSource.readOrInflate(InflaterSource.kt:76) at okio.InflaterSource.read(InflaterSource.kt:49) at okio.GzipSource.read(GzipSource.kt:69) at okio.RealBufferedSource$inputStream$1.read(RealBufferedSource.kt:161) at java.io.BufferedInputStream.read1(BufferedInputStream.java:284) at java.io.BufferedInputStream.read(BufferedInputStream.java:345) at java.io.FilterInputStream.read(FilterInputStream.java:107) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1309) at org.apache.commons.io.IOUtils.copy(IOUtils.java:978) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1282) at org.apache.commons.io.IOUtils.copy(IOUtils.java:953) at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:2405) at com.appiancs.msgraphmail.MSGraphMessageHandler.processProxied(MSGraphMessageHandler.java:114) at com.appiancs.msgraphmail.MSGraphMailPoller.processInboxItems(MSGraphMailPoller.java:168) at com.appiancs.msgraphmail.MSGraphMailPoller.pollForMail(MSGraphMailPoller.java:45) at com.appiancs.msgraphmail.MSGraphMailPollerSmartService.run(MSGraphMailPollerSmartService.java:212) at com.appiancorp.process.runtime.framework.DefaultActivityExecutor$1.lambda$call$0(DefaultActivityExecutor.java:136) at com.appiancorp.plugins.PluginUsageLogger.runWithPluginInformation(PluginUsageLogger.java:54) at com.appiancorp.process.runtime.framework.DefaultActivityExecutor$1.call(DefaultActivityExecutor.java:136) at com.appiancorp.process.runtime.framework.DefaultActivityExecutor$1.call(DefaultActivityExecutor.java:130) at com.appiancorp.common.ContextClassLoaderSwitcher.runInContext(ContextClassLoaderSwitcher.java:28) at com.appiancorp.process.runtime.framework.DefaultActivityExecutor.execute(DefaultActivityExecutor.java:130) at com.appiancorp.process.engine.UnattendedJavaActivityRequest.execute(UnattendedJavaActivityRequest.java:88) at com.appiancorp.process.engine.UnattendedJavaActivityRequestResponseCreator.getJavaActivityResultResponse(UnattendedJavaActivityRequestResponseCreator.java:22) at com.appiancorp.process.engine.UnattendedJavaActivityRequest.getJavaActivityResultResponse(UnattendedJavaActivityRequest.java:67) at com.appiancorp.process.engine.UnattendedJavaActivityRequest.execute0(UnattendedJavaActivityRequest.java:55) at com.appiancorp.common.persistence.data.AppianDataUserContextProvider.executeWithConsistentDataReads(AppianDataUserContextProvider.java:143) at com.appiancorp.process.engine.ProcessContinuationRequest.executeOuter(ProcessContinuationRequest.java:68) at com.appiancorp.process.engine.ContinuationRequest.execute(ContinuationRequest.java:129) at com.appiancorp.process.workpoller.UnattendedRequestHandlerBean.onMessage(UnattendedRequestHandlerBean.java:36) at com.appiancorp.process.workpoller.WorkItem.run(WorkItem.java:110) at org.springframework.jca.work.SimpleTaskWorkManager$DelegatingWorkAdapter.run(SimpleTaskWorkManager.java:241) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) 2024-05-02 06:55:57 SEVERE [Appian Work Item - 5540727 - WorkID 205 - execution02 - process 55985372 - model 1460 : UnattendedJavaActivityRequest] com.microsoft.graph.logger.DefaultLogger.logError CoreHttpProvider[sendRequestInternal] - 408Error during http request 2024-05-02 06:55:57 SEVERE [Appian Work Item - 5540727 - WorkID 205 - execution02 - process 55985372 - model 1460 : UnattendedJavaActivityRequest] com.microsoft.graph.logger.DefaultLogger.logError Throwable detail: com.microsoft.graph.core.ClientException: Error during http request 2024-05-02 06:55:57,065 [Appian Work Item - 5540727 - WorkID 205 - execution02 - process 55985372 - model 1460 : UnattendedJavaActivityRequest] ERROR com.appiancs.msgraphmail.MSGraphMailPoller - Error during email processing, exiting all com.microsoft.graph.core.ClientException: Error during http request at com.microsoft.graph.http.CoreHttpProvider.processResponse(CoreHttpProvider.java:494) at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:408) at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:225) at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:202) at com.microsoft.graph.http.BaseRequest.send(BaseRequest.java:335) at com.microsoft.graph.requests.MessageMoveRequest.post(MessageMoveRequest.java:54) at com.appiancs.msgraphmail.MSGraphMessageHandler.processProxied(MSGraphMessageHandler.java:252) at com.appiancs.msgraphmail.MSGraphMailPoller.processInboxItems(MSGraphMailPoller.java:168) at com.appiancs.msgraphmail.MSGraphMailPoller.pollForMail(MSGraphMailPoller.java:45) at com.appiancs.msgraphmail.MSGraphMailPollerSmartService.run(MSGraphMailPollerSmartService.java:212) at com.appiancorp.process.runtime.framework.DefaultActivityExecutor$1.lambda$call$0(DefaultActivityExecutor.java:136) at com.appiancorp.plugins.PluginUsageLogger.runWithPluginInformation(PluginUsageLogger.java:54) at com.appiancorp.process.runtime.framework.DefaultActivityExecutor$1.call(DefaultActivityExecutor.java:136) at com.appiancorp.process.runtime.framework.DefaultActivityExecutor$1.call(DefaultActivityExecutor.java:130) at com.appiancorp.common.ContextClassLoaderSwitcher.runInContext(ContextClassLoaderSwitcher.java:28) at com.appiancorp.process.runtime.framework.DefaultActivityExecutor.execute(DefaultActivityExecutor.java:130) at com.appiancorp.process.engine.UnattendedJavaActivityRequest.execute(UnattendedJavaActivityRequest.java:88) at com.appiancorp.process.engine.UnattendedJavaActivityRequestResponseCreator.getJavaActivityResultResponse(UnattendedJavaActivityRequestResponseCreator.java:22) at com.appiancorp.process.engine.UnattendedJavaActivityRequest.getJavaActivityResultResponse(UnattendedJavaActivityRequest.java:67) at com.appiancorp.process.engine.UnattendedJavaActivityRequest.execute0(UnattendedJavaActivityRequest.java:55) at com.appiancorp.common.persistence.data.AppianDataUserContextProvider.executeWithConsistentDataReads(AppianDataUserContextProvider.java:143) at com.appiancorp.process.engine.ProcessContinuationRequest.executeOuter(ProcessContinuationRequest.java:68) at com.appiancorp.process.engine.ContinuationRequest.execute(ContinuationRequest.java:129) at com.appiancorp.process.workpoller.UnattendedRequestHandlerBean.onMessage(UnattendedRequestHandlerBean.java:36) at com.appiancorp.process.workpoller.WorkItem.run(WorkItem.java:110) at org.springframework.jca.work.SimpleTaskWorkManager$DelegatingWorkAdapter.run(SimpleTaskWorkManager.java:241) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) Caused by: com.google.gson.JsonSyntaxException: java.net.SocketTimeoutException: timeout at com.google.gson.Gson.fromJson(Gson.java:1006) at com.google.gson.Gson.fromJson(Gson.java:929) at com.microsoft.graph.serializer.DefaultSerializer.deserializeObject(DefaultSerializer.java:104) at com.microsoft.graph.http.CoreHttpProvider.handleJsonResponse(CoreHttpProvider.java:538) at com.microsoft.graph.http.CoreHttpProvider.processResponse(CoreHttpProvider.java:467) ... 28 more Caused by: java.net.SocketTimeoutException: timeout at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.kt:675) at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.kt:684) at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.kt:379) at okhttp3.internal.connection.Exchange$ResponseBodySource.read(Exchange.kt:276) at okio.RealBufferedSource.read(RealBufferedSource.kt:192) at okio.RealBufferedSource.request(RealBufferedSource.kt:209) at okio.RealBufferedSource.require(RealBufferedSource.kt:202) at okio.GzipSource.consumeHeader(GzipSource.kt:104) at okio.GzipSource.read(GzipSource.kt:62) at okio.RealBufferedSource$inputStream$1.read(RealBufferedSource.kt:161) at java.io.BufferedInputStream.read1(BufferedInputStream.java:284) at java.io.BufferedInputStream.read(BufferedInputStream.java:345) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) at java.io.InputStreamReader.read(InputStreamReader.java:184) at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1290) at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1328) at com.google.gson.stream.JsonReader.consumeNonExecutePrefix(JsonReader.java:1605) at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:534) at com.google.gson.stream.JsonReader.peek(JsonReader.java:425) at com.google.gson.Gson.fromJson(Gson.java:987)
  • This error occurs in the exception handling, so there should be an error ahead of it - can you share a larger log please?

    That said, there are some exception handling improvements that can be made to handle the exception on the exception better. Right now the error is "swallowed" and completes without providing sufficient information back to the designer.

  • Just some more details on the error - connection fails with http 408 error while trying downloading email with large attachment

  • We use the latest mail poller version

  • Which version of the poller are you using?

  • Hi Mike, the issue is with the plugin itself. We don't see those emails reported as exceptions, they are being moved without an error visible in the process model. 

    However, when I check the tomcat log, I can see network exceptions: 

    ERROR com.appiancs.msgraphmail.MSGraphMailPoller - Error during email processing, exiting all
    com.microsoft.graph.core.ClientException: Error during http request
    	at com.microsoft.graph.http.CoreHttpProvider.processResponse(CoreHttpProvider.java:494)
    	at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:408)
    	at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:225)
    	at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:202)
    	at com.microsoft.graph.http.BaseRequest.send(BaseRequest.java:335)
    	at com.microsoft.graph.requests.MessageMoveRequest.post(MessageMoveRequest.java:54)
    	at com.appiancs.msgraphmail.MSGraphMessageHandler.processProxied(MSGraphMessageHandler.java:252)
    	at com.appiancs.msgraphmail.MSGraphMailPoller.processInboxItems(MSGraphMailPoller.java:168)
    	at com.appiancs.msgraphmail.MSGraphMailPoller.pollForMail(MSGraphMailPoller.java:45)
    	at com.appiancs.msgraphmail.MSGraphMailPollerSmartService.run(MSGraphMailPollerSmartService.java:212)
    etc.... I can provide more detailed log as well