11-24-2009 10:51 AM - last edited on 11-24-2009 10:53 AM
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
Solved! Go to Solution.
11-24-2009 11:08 AM
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
11-24-2009 11:16 AM
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,
11-24-2009 02:54 PM
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!?
11-24-2009 04:28 PM
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.
01-08-2010 03:59 PM
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.
01-15-2010 10:24 AM - last edited on 01-15-2010 10:25 AM
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
01-17-2010 09:02 PM
Thank you, Zarrorulz!