Question on check the checkbox in a webpage with httpclient API

N

ngxfer001

Dear Experts,

Sorry to bother everyone, I have used httpclient to login my webmail
(squirrelmail) successfully, now I would like to flag unread for the
read email.

the procedure is as follows:
1) check the check box next to mail.

<td align="center" bgcolor="#ededed"><input name="msg[0]"
value="24446" type="checkbox"></td>
<td title="(e-mail address removed)" align="left"
bgcolor="#ededed"><b>"JBClub.net $B>>K\(B"</b></td>
<td align="center" bgcolor="#ededed" nowrap="nowrap"><b>10:11 pm</b></
td>
<td align="center" bgcolor="#ededed"
nowrap="nowrap"><b><small>&nbsp;</
small></b></td>
<td align="left" bgcolor="#ededed"><b><a href="read_body.php?
mailbox=INBOX&amp;passed_id=24446&amp;startMessage=1" title="Fw:
[AFL1530413*10000451] Mr. Kakuya Ide">Fw: [AFL1530413*10000451] Mr.
Kakuy...</a></b></td>
</tr>
<tr><td colspan="5" bgcolor="#dcdcdc" height="1"></td></tr>
<tr valign="top">

2) press the button to mark it unread. The button html code is as
follows.

<table border="0" width="100%" cellpadding="0"
cellspacing="0"><tr><td><form name="FormMsgsINBOX" method="post"
action="move_messages.php">
<input type="hidden" name="msg" value="">

<input type="hidden" name="mailbox" value="INBOX">
<input type="hidden" name="startMessage" value="1">

<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr
bgcolor="#dcdcdc"><td align="left"><table bgcolor="#ffffff" border="0"
width="100%" cellpadding="1" cellspacing="0"><tr><td
align="left"><font color="#ababab">Previous</font>&nbsp;|&nbsp;<a
href="right_main.php?
use_mailbox_cache=0&amp;startMessage=16&amp;mailbox=INBOX" >Next</
a>&nbsp;|&nbsp;1&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=16&amp;mailbox=INBOX" >2</
a>&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=31&amp;mailbox=INBOX" >3</
a>&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=46&amp;mailbox=INBOX" >4</
a>&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=61&amp;mailbox=INBOX" >5</
a>&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=76&amp;mailbox=INBOX" >6</
a>&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=91&amp;mailbox=INBOX" >7</
a>&nbsp;...&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=1711&amp;mailbox=INBOX" >115</
a>&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=1726&amp;mailbox=INBOX" >116</
a>&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=1741&amp;mailbox=INBOX" >117</
a>&nbsp;<a href="right_main.php?
use_mailbox_cache=0&amp;startMessage=1756&amp;mailbox=INBOX" >118</
a>&nbsp;|&nbsp;<a href="right_main.php?
PG_SHOWALL=1&amp;use_mailbox_cache=0&amp;startMessage=1&amp;mailbox=INBOX"
Show All</a>&nbsp;|&nbsp;<script language="JavaScript" type="text/
javascript">
<!--
function CheckAllINBOX() {
for (var i = 0; i < document.FormMsgsINBOX.elements.length; i++) {
if(document.FormMsgsINBOX.elements.type == 'checkbox'){
document.FormMsgsINBOX.elements.checked = !
(document.FormMsgsINBOX.elements.checked);
}
}
}
//-->

</script><a href="javascript:void(0)"
onClick="CheckAllINBOX();">Toggle All</a>
</td>
<td align="right">Viewing Messages: <b>1</b> to <b>15</b> (1766
total)</td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr><tr><td height="5" bgcolor="#ffffff"></td></tr><tr><td><tr>

<td align="left">
<table bgcolor="#ababab" border="0" width="100%" cellpadding="1"
cellspacing="0">
<tr><td><table bgcolor="#dcdcdc" border="0" width="100%"
cellpadding="1" cellspacing="0">
<tr><td align="left" nowrap><small>Move Selected To:&nbsp; </small></
td>
<td align="right" nowrap><small>Transform Selected Messages:&nbsp; </
small></td>
</tr>
<tr>

<td align="left" valign="middle" nowrap>
<small>&nbsp;<tt><select name="targetMailbox"><option
value="INBOX">INBOX</option>

<option value="INBOX.Drafts">INBOX.Drafts</option>
<option value="INBOX.Sent">INBOX.Sent</option>
<option value="INBOX.Trash">INBOX.Trash</option>
<option value="INBOX.Junk">INBOX.Junk</option>
</select></tt>&nbsp;<input type="SUBMIT" name="moveButton"
value="Move">
<input type="SUBMIT" name="attache" value="Forward">
</small></td>
<td align="right" nowrap="nowrap">

<input name="markRead" value="$B4{FI(B" type="submit"><input
name="markUnread" value="$BL$FI(B" type="submit"><input name="delete"
value="$B:eek:=|(B" type="submit">&nbsp;
<input name="location" value="/www.s188.xrea.com/mail/src/
right_main.php?&amp;startMessage=1&amp;mailbox=INBOX" type="hidden">
</td>


I have done the following:

PostMethod checkpost = new PostMethod(FRONT_PAGE +
"move_messages.php");
NameValuePair msg1 = new NameValuePair("msg[0]", "24446");
NameValuePair button = new NameValuePair("msg", "markUnread");
checkpost.setRequestBody(new NameValuePair[] {msg1, button});
client.executeMethod(checkpost);
System.out.println("Login form post: " +
checkpost.getStatusLine().toString());

This code doesn't seems to work, can you point me into the new
direction on how to do that?

thank you very much for helping me.

Best Regards
Ferdinand Ng
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top