Exchange web services (EWS) - Exchange client module

2
Hi All, I proposed a solution to our client where I want to retrieve emails from outlook inbox (or specific folder) and generate workflow based on email so that users don't have to manually create a workflow and attach emails or any other attachments within the email. I thought IMAPPOP3email module on the app store is the best fit to implement this (which i think it is and it works perfect in my POC) but unfortunately the technical architect said they cannot open the exchange server port and instead they recommended EWS will be better option. So I started looking into EWS and found one module Exchange client (2007 and up) but this was developed in Mendix version 3 and needs upgrading. I have seen a forum post here by Chris de Gelder, asking if there is any plan to upgrade/migrate exchange client to open source microsoft EWS for Java but I can't see any response to this post or don't know if this is already been migrated by someone who can help? Please can someone help to answer if this module is going to be upgraded/migrated or if anyone has already done this? Really appreciate and thank you in advance as this will be a great help to make a decision on the next steps.
asked
1 answers
3

Hi Mohammed

I have a small and customer specific implementation of EWS in a Mendix-module which contains:

  1. Synchronize contacts
  2. Update contact
  3. Create draft email

If you know Java you can write it yourself. The latter is:

    // BEGIN USER CODE
    logger.info("Create draft email");
    if (settings == null || settings.getUsername() == null || settings.getUsername().isEmpty()) {
        throw new UserThrownException("To use Exchange the settings must be valid (SyncContacts)"); 
    }       
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
    ExchangeCredentials credentials = new WebCredentials(settings.getUsername(), settings.getPassword(), settings.getDomain());
    service.setCredentials(credentials);
    service.setUrl(new URI(settings.getURL()));
    try 
    {
        EmailMessage replymessage = new EmailMessage(service);
        EmailAddress fromEmailAddress = new EmailAddress(from);
        replymessage.setFrom(fromEmailAddress);
        for(Iterator<relations.proxies.Contact> address = addressees.iterator(); address.hasNext(); ) {
            relations.proxies.Contact ad = address.next();
            if (ad.getEmail() != null) {
                replymessage.getToRecipients().add(ad.getEmail());
            }
        }            
        //replymessage.setInReplyTo(recipients);
        replymessage.setSubject(subject);
        replymessage.setBody(new MessageBody(body));
        replymessage.save();

    }catch (Exception e)
    {
        logger.error(""+e);
    }
    logger.info("msExchange send mail done");
    return true;
    // END USER CODE
answered