Iβm interested in the way to programmatically log into OWA (Microsoft Outlook Web Access - web-based email client) from Java code and get nothing more than an unread Inbox account - I can read this number from the inbox of the HTML page - but the problem is what happens there is a login.
In fact, if you look at the HTML source on the OWA login page, I see that there is an HTML form element:
<form action="owaauth.dll" method="POST" name="logonForm" autocomplete="off">
which gets the button element inside it:
<input type="submit" class="btn" value="Log On" onclick="clkLgn()">
From the study of the clkLgn () script, I found that it sends a cookie to the document, so it may not be critical:
function clkLgn()
{
if(gbid("rdoPrvt").checked)
{
var oD=new Date();
oD.setTime(oD.getTime()+2*7*24*60*60*1000);
var sA="acc="+(gbid("chkBsc").checked?1:0);
var sL="lgn="+gbid("username").value;
document.cookie="logondata="+sA+"&"+sL+";expires="+oD.toUTCString();
}
}
Basically, how can I submit this form? The following code is my attempt at a problem, I can make an HTTP connection, but I can not show the POST the correct HTTP request.
URL urlObject = new URL(url);
HttpURLConnection hConnection = (HttpURLConnection)urlObject.openConnection();
HttpURLConnection.setFollowRedirects(true);
hConnection.setDoOutput(true);
hConnection.setRequestMethod("POST");
PrintStream ps = new PrintStream(hConnection.getOutputStream());
ps.print("username="+username+"&password="+password);
ps.close();
hConnection.connect();
if( HttpURLConnection.HTTP_OK == hConnection.getResponseCode() )
{
InputStream is = hConnection.getInputStream();
OutputStream os = new FileOutputStream("output.html");
int data;
while((data=is.read()) != -1)
{
os.write(data);
}
is.close();
os.close();
hConnection.disconnect();
}
.