02-22-2009 10:23 AM
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
02-22-2009 01:49 PM
As far as I know it is not possible to walk trough already saved messages.
02-24-2009 12:24 PM
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.
02-24-2009 12:47 PM
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!
02-25-2009 08:11 AM
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
02-25-2009 01:57 PM
02-26-2009 04:27 AM
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."); }
02-27-2009 03:06 AM