Pregunta

I tried to use the following code to send mail using EWS Java API. But I get the error that the NTLM Authentication is selected. I need only Basic Authentication. How do I specify the authentication type.

    ExchangeCredentials credentials = new WebCredentials("user", "pwd");
    service.setCredentials(credentials);
    try {
        service.setUrl(new java.net.URI("https://url/EWS/Exchange.asmx"));
        service.setTraceEnabled(true);

        EmailMessage msg = new EmailMessage(service);
        msg.setSubject("Hello world!");
        msg.setBody(MessageBody
                .getMessageBodyFromText("Sent using the EWS Managed API."));
        msg.getToRecipients().add("email");
        msg.send();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Please tell me how to solve this....:(

¿Fue útil?

Solución

It depends on the configuration of you exchange server. Try using the different usernames who can be configured on exchange servers:

ExchangeService service = new ExchangeService();

ExchangeCredentials credentials = new WebCredentials("user@domain.com","pass");

or

ExchangeCredentials credentials = new WebCredentials(Username,Password, domain);

or

ExchangeCredentials credentials = new WebCredentials("user", "pwd");

service.setCredentials(credentials);

In my case, the one who works is the Username,Password,Domain method.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top