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
New Developer
yong9900
Posts: 4
Registered: 11-12-2009

can't make attachment to the original email in the SendListener.sendMessage method

Hi,

 

I want to make an attachment to the email before it's sent out, so I apply following in SendListener.sendMessage method. But the email can't be sent out. In my sent folder, the email was marked by a red "X".

 

Can someone let me know what's the problem (I traced and my original email has normal bodypart content)?

 

thanks,

Mike

 

codes in SendListener.sendMessage:

 

//for normal bodypart content

            if (content instanceof BodyPart) {

                    TextBodyPart part = (TextBodyPart)content;
                    if ( part.hasMore() && (!part.moreRequestSent()) ) {
                        System.out.println("get data from server for single body part");
                        Transport.more(part, true);
                        while (part.hasMore()) {
                            try {
                                System.out.println("wait for the message...");
                                Thread.sleep(1000); //sleep 1 sec
                            } catch (Throwable e) {
                                e.printStackTrace();
                            }
                        }
                    }

                bodyText = (String)part.getContent();

                Multipart multipart = new Multipart(); // Default type of multipart/mixed.
                
                TextBodyPart tbp = new TextBodyPart(multipart, bodyText);
                SupportedAttachmentPart attach = new SupportedAttachmentPart( multipart, "text/plain", "data.txt", "abc");
                //multipart.addBodyPart((BodyPart)content);
                //System.out.println("add old content to the new multipart");
                multipart.addBodyPart(tbp);
                multipart.addBodyPart(attach); // Add the attachment to the multipart.
                msg.setContent(multipart);
                System.out.println("reset the content to the new multipart");
            }

 

 

Please use plain text.
Administrator
MSohm
Posts: 10,873
Registered: 07-09-2008
My Carrier: Bell

Re: can't make attachment to the original email in the SendListener.sendMessage method

What BlackBerry Smartphone model and BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.