How to check a checkbox with httpclient?

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.

<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 + "right_main.php?
use_mailbox_cache=0&startMessage=1&mailbox=INBOX");
NameValuePair msg1 = new NameValuePair("msg[0]", "24384");
checkpost.setRequestBody(new NameValuePair[] {msg1});
client.executeMethod(checkpost);

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
 
N

ngxfer001

Sorry,

My program should be like this which doesn't work.

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

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

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,096
Latest member
ThurmanCre

Latest Threads

Top