Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 40
Registered: ‎10-22-2010
My Device: 9800 Torch
My Carrier: AirTel
Accepted Solution

Programmatically set message from Inbox as Read....

 

 

Hi all,

 

  I am developing one application where i persist e-mails messages coming to me from particular senders.I access those persisted mails in my application and do Approve or Reject action on those mails through my app.In both cases(Approve and Reject),i send mails from where i have got that mail.

    But i want to mark mail in my Blackberry Email Inbox as READ when i approve/reject that mail from my application.I succeded in finding mail from inbox which i have approved/rejected from my app. but when I set that mail as read that mail from Inbox doesnt get marked as read....

 

I get array of mails from inbox as folllows..

 

 

 

Folder[] folders= store.list(Folder.

INBOX);

Folder inboxFolder;

inboxFolder = folders[0];

Message[] messages =null;

 

try{

messages = inboxFolder.getMessages();

}

catch(MessagingException e1) {

 

// TODO Auto-generated catch block

e1.printStackTrace();

 

and when i mark mail as read from "messages" folder...How can mark it as read from inbox folder......

 

 

for (int i=0;i<messages.length;i++){

       String receiveddateTime = dateFormat.format(messages[i].getReceivedDate());

       if(receiveddateTime.equals(messageDTO.getDateTime()) && messages[i].getSubject().equals (messageDTO.getSubject())){

messages[i].setStatus(Message.Status.

TX_READ, Message.Status.RX_ERROR);

 }

}

 

above code marks mail from "messages" as Read and not from inbox.....

 

 

Thanking you in anticipation...

 

Shivdattam

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Programmatically set message from Inbox as Read....

Assuming that you have a reference to the Message object:

 

       message.setFlag(Message.Flag.OPENED,true);

Contributor
Posts: 40
Registered: ‎10-22-2010
My Device: 9800 Torch
My Carrier: AirTel

Re: Programmatically set message from Inbox as Read....

Thanks RexDough,

 

      Reference to message object is actually to the Message object in Arrray of messages got by getMessages on Inbox....how i should refer to message object of Inbox.....

Highlighted
Developer
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: Programmatically set message from Inbox as Read....

As far I know, we can not access Inbox messages. So we can only listen incomming messages, not modify inbox message.

Contributor
Posts: 40
Registered: ‎10-22-2010
My Device: 9800 Torch
My Carrier: AirTel

Re: Programmatically set message from Inbox as Read....

Hi All,

 

    I worked out solution myself....

 

Instead of storing messages in an array and setting them as opened,i  can directly set messages as read as follows...

 

inbox is Inbox Folder from store....

 

for

(int i =0;i<inbox.getMessages().length;i++){

String receivedDate = dateFormat.format(inbox.getMessages()[i].getReceivedDate());

if(inbox.getMessages()[i].getFrom().getAddr().equals(messageDTO.getFromAddr()) && receivedDate.equals(messageDTO.getDateTime())){

inbox.getMessages()[i].setFlag(Message.Flag.

OPENED,true);

 

break;

}

}

 

 

Thanks All...

Shivdatta