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
Developer
Posts: 15
Registered: ‎08-14-2008
My Device: 8300 with 4.5.0.52 b75 OS

Create inbox message or modify incoming message

I have a problem to change incoming message into another.

 

I recieve a message, usingFolderListener and method messagesAdded(FolderEvent e) i can get the message.

Then, i would like to do either one of this scenario:

1. remove attachment in the inbox message and insert new one 

or

2. create new inbox message that will looks like an incoming message and contains attachment (word type)

 

For first one, i've tried something like :

- get message from FolderEvent using

        e.getMessage()

- get content of message using

        lObject = msg.getContent();

- retyping it into Multipart (the mail is having the attachment, so it is multipart) :

        Multipart lPart = (Multipart) lObject;

- create SupportedAttachmentPart

        SupportedAttachmentPart attach = new SupportedAttachmentPart( lPart, "application/msword", "test.doc" , lData);

- Insert it into message  

        lPart.addBodyPart(attach);

 

But with no succes, the attachment was not there.

 

Then i'we tried to create new message using this code/function :

 

 public void CreateMessage(String iAttachmentName, byte[] iAttachmentData)
   
        
        Store store = Session.getDefaultInstance().getStore();
        Folder inbox;
        try
        {

           inbox = store.getFolder("Inbox");
        }
                
        catch(MessagingException e)        
        {  
            return;
        }
        
        Message msg = new Message(inbox);
        
        Address toList[] = new Address[1];
        try
        {
          toList[0] = new Address("blazej@blazckberry.com", "BlazejBB");
        }
        catch(AddressException e)
        {
        }
        
        try
        {
          msg.addRecipients(Message.RecipientType.TO, toList);
        }
        catch(MessagingException e)
        {
        }
        
        msg.setSubject("Sample generated message");

        Multipart multipart = new Multipart();
        SupportedAttachmentPart attach = new SupportedAttachmentPart( multipart, GetMimeType(iAttachmentName),  iAttachmentName, iAttachmentData );
        multipart.addBodyPart(attach);
        
        try
        {
          msg.setContent(multipart);

          inbox.appendMessage(msg);
        }
        catch(MessagingException e)
        {    }
    }

 

The message is created, but it's icon is the draft message icon, not the envelope i would like to have.

 

So, can i add attachment into incoming message? Or can i create new message in inbox that would looks like recieved message?

 

 Thanks

 

Blazej

Developer
Posts: 15
Registered: ‎08-14-2008
My Device: 8300 with 4.5.0.52 b75 OS

Re: Create inbox message or modify incoming message

Hmm,

 

after 'walking' and watching all topics in this forum, i've found this one

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=2229

 

so hopefully this would help me with no. 2.

Highlighted
BlackBerry Development Advisor
Posts: 15,209
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Create inbox message or modify incoming message

[ Edited ]

What type of attachment are you trying to update?  What is your target BlackBerry handheld software version?

 

Note that doing this can prevent the attachment from being displayed to the user because the attachment no longer went through the Attachment Distiller on the BlackBerry Enterprise Server.

Message Edited by MSohm on 08-21-2008 11:33 AM
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 15
Registered: ‎08-14-2008
My Device: 8300 with 4.5.0.52 b75 OS

Re: Create inbox message or modify incoming message

I'm recieving encrypted attachment, extension is .scef. This contains encrypted email (mime mail). Then i exctract attachments that are stored inside and append them into new mail, ie. i'm reconstructing the original mail. The first way was to replace the original mail with the new one, now, but i was not able to do that. Now, i'm creating new one with content from decrypted attachment.

 

My BB software 4.5.0.52 , build 75.

 

Problem with displaying attachmentthat had not come through the BES  is solved using Doc2Go.