Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
Zorrorulz
Posts: 37
Registered: 04-02-2009
Accepted Solution

Message.forward not sending attachments

[ Edited ]

Hi,

 I am able to forward email by adding attachment through my program using GMAIL it works without any issues

 when I forward an email by attaching through my program and send it  with BES, I see the error:

  Sent Using: Desktop( Secure)

  Folder: sent Items

  Message Status : Error

 

 and the message is not sent.

 

 If I add the attachment manually and forward the email, it works.

 So there is no problem with the BES server.

 

 I am using Message.forward to create the forward message and  message.setContent(SAP) for attachment.

 

 Any help is greatly appreciated 

 

Please use plain text.
Developer
dpreussler
Posts: 212
Registered: 07-18-2008

Re: Message.forward not sending attachments

when sending an email with attachment imho you have to

 

use the message.setContent method with a Multipart instance which contains the attachment. an email with only attachment should be invalid.

 

 

Multipart multiContent = new Multipart("mixed"); 

multiContent.addBodyPart(sap);

message.setContent(multiContent);

 

but it's just a guess

If your problem was solved, please mark answer as "Accepted solution"
If your want to thank, click the "kudo" symbol
___________
visit me: http://mobilejavadevelopment.blogspot.com/
visit the Berlin BlackBerry Developer Group: http://berlinblackberrydevelopers.blogspot.com/
Please use plain text.
Developer
Zorrorulz
Posts: 37
Registered: 04-02-2009

Re: Message.forward not sending attachments

yep I have exactly used like the way you described.

 

My code that is not working is like this....

 

Multipart multipart = new Multipart();

multipart.addBodyPart(sap);

Message msg = message.forward();

msg.setContent(multipart);

 

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

Please use plain text.
Developer
dpreussler
Posts: 212
Registered: 07-18-2008

Re: Message.forward not sending attachments

I don't understand why do you want to reset the content on a forwarded message?

I assume the setcontent somehow destroyes the original message you get after calling msg.forward

 

simply forwarding leaved the attachments untouched if this is what you want to do!?

If your problem was solved, please mark answer as "Accepted solution"
If your want to thank, click the "kudo" symbol
___________
visit me: http://mobilejavadevelopment.blogspot.com/
visit the Berlin BlackBerry Developer Group: http://berlinblackberrydevelopers.blogspot.com/
Please use plain text.
Developer
Zorrorulz
Posts: 37
Registered: 04-02-2009

Re: Message.forward not sending attachments

My application requirements are like that.

when you are forwarding a mail, you have to attach another file to the forwarding message.

 

As I have been working from the Morning I realized that setting the content is the problem.

 

I  cloned the message and added the content its working fine except that its not taking the body part properly of the original message.The new attachments and the forward is working good.

 

I have to fix the content problem.

 

Please use plain text.
New Developer
cdiaz
Posts: 14
Registered: 09-07-2009

Re: Message.forward not sending attachments

Hi Zorrulz,

 

I need to do something similar in my application - basically clone an email message along with its content and any attachments.  How did you clone the message successfully with attachments?  Also, were you able to succesffully set the body part from the original message?

 

Thanks.

Please use plain text.
Developer
Zorrorulz
Posts: 37
Registered: 04-02-2009

Re: Message.forward not sending attachments

[ Edited ]

 

  public static Message cloneMessage(Message source,boolean forward)
        throws MessagingException
        {
            Message clone = new Message();
            //we are adding this in the actual calling method
          //  clone.setContent(source.getContent());
             
            // Cloning headers doesn't seem to work. It throws exceptions
            clone.setInbound(source.isInbound());
            clone.setPriority(source.getPriority());
            if(!forward){
                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());
            if(!forward)
              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);
        }

 

Hope that helps!!!.. You can tweak it to your needs

 

Please use plain text.
New Developer
cdiaz
Posts: 14
Registered: 09-07-2009

Re: Message.forward not sending attachments

Thank you, Zarrorulz!

Please use plain text.