Sending emails with EWS Java API from Mircosoft does not work/never ends RRS feed

  • Question

  • I am trying to send mails using EWS Java API from Microsoft like this:

    final ExchangeService service = new ExchangeService(); // ExchangeVersion.Exchange2010_SP1 );
    final ExchangeCredentials credentials = new WebCredentials( getMailAccount(), getPasswort() );
    service.setCredentials( credentials );

    service.setTraceEnabled( true );
    service.setTraceFlags( EnumSet.allOf( TraceFlags.class ) );
    service.setTraceListener( new ITraceListener()
        public void trace(
                String type,
                String message )
            System.out.println( "[" + type + "] " + message );
    } );

    service.setUrl( new URI( getUrl() ) );

    final EmailMessage msg = new EmailMessage( service );
    msg.setSubject( getSubject() );
    msg.setBody( MessageBody.getMessageBodyFromText( getText() ) );
    msg.getToRecipients().add( getRecipient() );


    The sender mail account is an O365 account so I used https://outlook.office365.com/EWS/Exchange.asmx as url. But when I try to send a mail nothing happens. Everything works fine till the last line msg.send(). When I do that nothing happens any more and the call for sending is running "forver". There is no error, no timeout, just nothing happens and the send() call does not return..

    Does anyone has an idea what could be the reason for this behaviour?

    Also in the trace. I can only see the outgoing messages but I recieve no answers, nothing to identify what the problem could be.

    I am using version 2.0 of the EWS Java API.

    Thanks a lot, Szdnez

    Monday, April 9, 2018 7:37 PM