Using Exchange Web Services for email

My exchange administrators are saying that I need Appian to use Exchange Web Services. How can I get Appian to talk using this protocol?

Thanks in advance. I did a search and I didn't see anything after 2015...

OriginalPostID-258508

  Discussion posts and replies are publicly visible

  • BTW, when I deployed your latest plug-in and executed from an expression rule, I got the following exception..

    Expression evaluation error at function a!fromJson [line 7]: Error evaluating function fn!fromjson_appian_internal : The jsonText parameter of a!fromJson() must not be null or empty.
  • 0
    Certified Lead Developer
    The function is returning null. so can you please check the logs for exception when you run the below code from expression rule to check the actual issue! It is working fine for me and successfully tested with few other credentials as well.

    getewsemails(
    email:"<emailId>",
    password : "<pwd>",
    numberOfEmails : 2
    )
  • Got it. The following is the error I see in logs.

    2017-01-25 16:30:59,091 [[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] ERROR com.incessant.plugins.exchangewebservice.GetEWSEmail - Exchange Web Service - EWS Recieve Email Function ERROR : microsoft.exchange.webservices.data.AutodiscoverLocalException: The Autodiscover service couldn't be located.
  • 0
    Certified Lead Developer
    So the problem is with the connection here too! Can you try to open your EWS URL in chrome or any(not in internet explorer). The request should be forwarded to <site>/ews/Services.wsdl and a WSDL should be send to the browser.
  • 0
    Certified Lead Developer
    And, It is better to go with auto discover service in the code due to following reasons,
    1. Auto discover determines the best endpoint for a given user (the endpoint that is closest to the user’s Mailbox server).
    2. The EWS URL might change as your administrators deploy new Client Access servers.
  • Hi Vinod, I am able to connect to the outlook and read the emails from our plug-in. Auto discovery is not working in our environment. Hence, I can't use your plug-in. But, I am able to deploy my plug-in and do basic testing so far. Thanks for your help !

    I need to read and send the email attachments as output from the plugin to the smart service. Can you suggest me what would be the return data type and how can I do that? What API should I use in plug-in? Do you have any sample code?
  • 0
    Certified Lead Developer
    You can use "Document" type to send the attachments as output for the smart service. Appian API will help you on this.
    forum.appian.com/.../

    1. Create Document object and set all the required properties.
    Document doc = new Document();
    doc.setName("Test Doc");....etc

    2. Create/Upload this document into Appian.
    cs.create(doc, ContentConstants.UNIQUE_NONE); where cs is a ContentService object

    3. Read the attachment data and write it to "doc" object using FileOutputStream
  • Hi Vinod..Thank you.

    I need help in doing the step 3 of your notes. I have the following code..

              for (Attachment attachment : emailMessage.getAttachments()) {
                                                      fileAttach = (FileAttachment) attachment;
                                                      OutputStream stream = new ByteArrayOutputStream();
                                                      fileAttach.load(stream);

    I couldn't find any sample code from other plug-ins from shared components.
  • 0
    Certified Lead Developer
    Once you created the document in Appian by using "create" method. Try to download it as below,

    Long newDocumentId = cs.create(doc, ContentConstants.UNIQUE_NONE);
    Document newDocument = cs.download(newDocumentId, ContentConstants.VERSION_CURRENT, false)[0];

    And, the next step is to copy the content from attachment to this "newDocument". This functionality we can achieve by using FileInputStream and FileOutputStream in Java.

    You can find many examples in google to copy content from one file to another file in java
  • Hi Vinod, our plug-in is now working as expected! Many thanks for your help and support!