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
New Developer
Posts: 5
Registered: ‎02-19-2009
My Device: Not Specified

Looking for some inbox help

Hi There,

 

Fairly new to the java RIM dev world.

 

I was wondering if anyone can help me. I am having some problems displaying the contents of a users inox.

 

For example: loop through inbox and display messages of high importance, etc.

 

Can anyone help?

 

Thanks

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Looking for some inbox help

As far as I know it is not possible to walk trough already saved messages.

 

Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: Looking for some inbox help

you can reach to Inbox folder using this piece of code

 

Store store = Session.getDefaultInstance().getStore();
Folder[] folders = store.list(Folder.INBOX);

 

but you cannot create any subfolder in it; instead of it you can insert your mails here in default inbox folder

 


If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish.

 

Deepesh Gupta
New Developer
Posts: 5
Registered: ‎02-19-2009
My Device: Not Specified

Re: Looking for some inbox help

Thanks Deepesh,

 

Once I get the folder list, do you know if there is a way to apply an "if" statement to that store list where I can say "get messages of high importance only?"

 

Thanks!

Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: Looking for some inbox help

You need to read all message objects then you can check their priorities and then you can refine them.

 

PS: If you need to thank, give Kudos

 

 


If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish

 

 

Deepesh Gupta
New Developer
Posts: 5
Registered: ‎02-19-2009
My Device: Not Specified

Re: Looking for some inbox help

Would it be too much to ask if you had some sample code I could get started with?
Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: Looking for some inbox help

In this example, we retrieve the msg from inbox and try to read bodypart of msg

 

 

Store store = null; Folder folder = null; try { //Get the default mail session. store = Session.waitForDefaultSession().getStore(); } catch (NoSuchServiceException ex) { //No message services found! System.out.println(ex.toString() + ": " + ex.getMessage()); } try { //Open the Inbox for the default mail session. //Open either the BWC or BES Inbox. //BWC Inbox //folder = store.getFolder("Web Client/Inbox"); //BES Inbox folder = store.getFolder("Inbox"); } catch (FolderNotFoundException ex) { //The Inbox was not found! System.out.println(ex.toString() + ": " + ex.getMessage()); } Message[] msgs = null; try { //Get all messages from the Inbox. msgs = folder.getMessages(); } catch (MessagingException ex) { System.out.println(ex.toString() + ": " + ex.getMessage()); } BodyPart bp; boolean moreMessage = false; //Loop until we find a message with more available. for (int count = 0; count < msgs.length; ++count) { bp = (BodyPart)msgs[count].getContent(); System.out.println("The body part is : "+ getBodyContent(bp)); if (( bp.hasMore() ) && (!bp.moreRequestSent())) { //A message with more available has been found! moreMessage = true; //Save the messageID messageID = msgs[count].getMessageId(); System.out.println("Has More : "); System.out.println("The body size of the message before more is: " + getBodyContent(bp).length()); //getBodyText can also be used to retreive a String based body of a message. System.out.println("The body size of the message before more is: " + msgs[count].getBodyText().length()); System.out.println("Requesting more for MessageID " + messageID); //Request more, specify true in the second parameter to request the rest of //the message body (up to a maximum of 32 kb). //Note that BWC does not support the true parameter of a more request. try { Transport.more(bp, true); } catch (MessagingException ex) { System.out.println(ex.toString() + ": " + ex.getMessage()); } //Add a message listener to this message so the application will //receive notification when the message has been changed. msgs[count].addMessageListener(this); break; } } if (!moreMessage) Dialog.alert("No messages with more available were found in the Inbox."); }

 

 
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish

 

Deepesh Gupta
Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: Looking for some inbox help

If your problem was get solved then please mark the thread as "Accepted solution"
Deepesh Gupta