BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-05-2009, 08:10 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default message body = null

Please Login to Remove!

Hi All,
i have return the following code for retriving email messages:
Code:
public void messagesAdded(FolderEvent e) {
    //get the message and folder it was added to
    final Message orginalMessage = e.getMessage();
    Folder messageFolder = orginalMessage.getFolder();

    //check that the folder was the inbox
    if (messageFolder.getType() == Folder.INBOX && orginalMessage.getMessageType() == Message.EMAIL_MESSAGE) {
        System.out.println("Message has arrived");
        Object content = orginalMessage.getContent();
        if (content instanceof BodyPart) {
            BodyPart bodyPart = (BodyPart) content;
            if (bodyPart.hasMore()) {
                if (!bodyPart.moreRequestSent()) {
                    orginalMessage.addMessageListener(this);
                    try {
                        Transport.more(bodyPart, true);
                        String subject = orginalMessage.getSubject();
                        Address addr = orginalMessage.getFrom();
                        String address = addr.getAddr();
                        String text = orginalMessage.getBodyText(); 
                        System.out.println("address: " + address);
                        System.out.println("subject: " + subject);
                        System.out.println("content: " + text);
                        
                    } catch (Exception z) {
                        System.out.println(z.toString());
                    }
                }
            } else {
                orginalMessage.removeMessageListener(this);
                String completeContent = orginalMessage.getBodyText();
            }
        }
        
    }
}
But everytime i am getting orginalMessage.getBodyText() as null. I want to retrive the message text from the message object. what am i doing wrong. Please help me.
__________________
Thanks
Meenal
Offline  
Old 03-05-2009, 08:23 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

On OS 4.5 and later, getBodyText() will return null if the email has HTML content.

You have to use getContent() and search the Body Parts for an HTML part.
Offline  
Old 03-06-2009, 12:08 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, .... I am not sure i understand. Can you give a code snippet or working example on how its done. Till thn i am trying on my own.
__________________
Thanks
Meenal
Offline  
Old 03-06-2009, 04:32 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

There is an article in the Developer KB that discusses the issue and contains a code example.

Look here:

Livelink - Redirection
Offline  
Old 03-09-2009, 07:00 AM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Thank you

Hey,

Thanks for the prompt reply. There they have given a sample application which works fine. So my query is solved.
Thankyou
__________________
Thanks
Meenal
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.