Sending an OWA logon form from Java

后端 未结 2 398
旧时难觅i
旧时难觅i 2020-12-18 16:06

I am interested in a way to programmatically log into OWA (Microsoft Outlook Web Access - a web-based email client) from Java code and retrieve nothing more than the inbox u

相关标签:
2条回答
  • 2020-12-18 16:17

    That JavaScript does certainly an important thing: it adds a cookie to the document. A decent HTTP client is required to send all valid cookies along the headers on every HTTP request. You should do the same programmatically. You can add headers using URLConnection#setRequestProperty().

    Further, there are several things to take into account as well when submitting forms programmatically: you should not skip any hidden input fields (input type="hidden"), those might be of relevance. You should also send the name=value pair of the submit button you'd like to press programmatically along as request parameter. Finally, you should not be using & to concatenate parameter pairs, but &.

    Note that I don't guarantee that it will finally work, that OWA thing might have some other prevention against bots, but it should solve the as far spotted problems.

    See also:

    • How to use URLConnection?

    By the way, have you considered just connecting it using a SMTP/IMAP API like JavaMail?

    0 讨论(0)
  • 2020-12-18 16:24

    Why go through a form? MS recently open sourced a Java client for their Exchange server API.

    http://blogs.office.com/2014/08/28/open-sourcing-exchange-web-services-ews-java-api/

    https://github.com/OfficeDev/ews-java-api

    0 讨论(0)
提交回复
热议问题