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
Regular Contributor
beemaster
Posts: 51
Registered: ‎06-29-2011
My Device: Z10 Limited Edition

Get/modify attachments in email

Hi!

 

I am developing mail encryption plugin for Blackberry. I use JDE 5.0 and 9700 simulator. What I want is to get/modify attachments in email before they are sent. 

 

First, here is a function, which I found somewhere on this forum:

private void findEmailBody(Object obj)
{
    if(obj instanceof Multipart)
    {
        Multipart mp = (Multipart)obj;
        for(int count=0; count < mp.getCount(); ++count)
        {
            findEmailBody(mp.getBodyPart(count));
        }
    }
    else if (obj instanceof TextBodyPart)
    {
        ....
    }
    else if (obj instanceof MimeBodyPart)
    {
        ....
    }
    else if ((obj instanceof SupportedAttachmentPart) || (obj instanceof UnsupportedAttachmentPart))
    {
        ....
    }
}

 I call that function before email has been sent:

void processMessage(Message message)
{
    findEmailBody(message.getContent());
}

 

The problem is: I never get in if branches, that process attachments.

- If I am sending an email without attachments, I have 1 TextBodyPart

- If I attach an image, I have 1 Multipart with 1 TextBodyPart inside

- If I attach a contact I have 1 TextBodyPart.

 

WTF? Where are my attachments?

 

I looked into debugger and found this: http://dl.dropbox.com/u/21467/att.png

This proves that object has attachment inside. How to get it? I guess I can not use reflection to acess private members, thats bad.

 

Is there any way to get that attachment? Please, help me!

 

Please use plain text.