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: 45
Registered: ‎01-05-2009
My Device: Not Specified
Accepted Solution

Send option not available when i use msg.reply(true,true) for email

Hi  

 

I don't have a Send option when replying to a email below is the code for that :

 

Message newMessage = msg.reply(true,true); 

Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES,new MessageArguments(newMessage)); 

 

but if i do

 

Message newMessage = msg.forward(); 

Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES,new MessageArguments(newMessage)); 

 

and enter address in To field it shows  Send option.

 

any idea about this ??

 

Thanks

Gautam 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Send option not available when i use msg.reply(true,true) for email

This is a known bug in the Message object. And before you go to the trouble of checking, ReplayAll() also fails.

 

The work-around that we coded is to use msg.forward(), and then hack the resulting message object by adding the correct "reply-to" address or addresses, and doctoring the "Subject" line.

 

I suggest you give this a shot. I reported the issue to RIM months ago and AFAIK there is no fix or work-around. This issue goes all the way back to 4.2.

 

 

 

Developer
Posts: 45
Registered: ‎01-05-2009
My Device: Not Specified

Re: Send option not available when i use msg.reply(true,true) for email

thanks a lot.
Developer
Posts: 42
Registered: ‎10-06-2008
My Device: Not Specified

Re: Send option not available when i use msg.reply(true,true) for email

What do you do if there are attachments though? I'm assuming that Forward sends all attachments along with it, which is something you might not want to do for Reply
Developer
Posts: 45
Registered: ‎01-05-2009
My Device: Not Specified

Re: Send option not available when i use msg.reply(true,true) for email

i think we can remove the attachment as below 

 

 Object o = msg.getContent();

        

            if(o instanceof Multipart)

            {

                try

                {

                    Multipart m = (Multipart)o;

                    for(int i=0;i<m.getCount();i++)

                    {

                        BodyPart Bp = (BodyPart)m.getBodyPart(i);

                        if(Bp instanceof SupportedAttachmentPart)

                        {

                            m.removeBodyPart(Bp);

                        }

                    }

                }

                catch(Exception e)

                {

                }

            } 

Developer
Posts: 157
Registered: ‎02-18-2009
My Device: Not Specified

Re: Send option not available when i use msg.reply(true,true) for email

[ Edited ]

As a possible workaround (works for me) you could try to clone the reply message:

 

// create a reply and clone if as a workaround
Message replyMessage = MessageUtils.cloneMessage(sourceMessage.reply(false));
MessageArguments messageArguments = new MessageArguments(replyMessage);
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, messageArguments);

[cloneMessage]

/**
* Clones the message.
*/
public static Message cloneMessage(Message source)
throws MessagingException
{
Message clone = new Message();

clone.setContent(source.getContent());

// Cloning headers doesn't seem to work. It throws exceptions
clone.setInbound(source.isInbound());
clone.setPriority(source.getPriority());

if (source.getReplyTo() != null) clone.setReplyTo(source.getReplyTo());
if (source.getSentDate() != null) clone.setSentDate(source.getSentDate());
if (source.getSubject() != null) clone.setSubject(source.getSubject());
if (source.getFrom() != null) clone.setFrom(source.getFrom());

cloneRecipients(source, clone, Message.RecipientType.TO);
cloneRecipients(source, clone, Message.RecipientType.CC);
cloneRecipients(source, clone, Message.RecipientType.BCC);

return clone;
}

 

public static void cloneRecipients(Message source, Message target, int type)
throws MessagingException
{
Address[] sourceRecipients = source.getRecipients(type);

target.addRecipients(type, sourceRecipients);
}
 

 


Martijn Brinkers

 

Message Edited by martijnbrinkers on 02-26-2009 03:50 PM
Highlighted
Developer
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: Send option not available when i use msg.reply(true,true) for email

How to keep the attachement part ,if we do reply with edit/reply all with edit.

Thanks, in advance...