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
New Developer
Posts: 72
Registered: ‎08-28-2008
My Device: Not Specified

SupportedAttachmentPart ??

[ Edited ]

Hi All,

i am trying to send an email with audio attachment programatically. i am using below statments to attach an audio in email message.

 

Object content = message.getContent();
Multipart mp = (Multipart) ((BodyPart) content).getParent();

SupportedAttachmentPart sap = new SupportedAttachmentPart(mp ,"audio/amr","audio.amr",audiobytes);
mp.addBodyPart(sap);

 


when i send mail progrmatically, It shows cross sign in the message box. it looks like i am doing something wrong.Can anyone tell where i am doing wrong

Thanks in advance

 

 

Message Edited by vijaysaini on 02-06-2009 04:13 PM
Regards,
Vijay Saini.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 33
Registered: ‎07-16-2008
My Device: Not Specified

Re: SupportedAttachmentPart ??

maybe this posting helps you in understanding basics:

old forum gzip attachment

Regards

Anil

 

New Developer
Posts: 72
Registered: ‎08-28-2008
My Device: Not Specified

Re: SupportedAttachmentPart ??

Hi All,

I have tried the knowlege Base article DB-00009 sample code and it's working. but when i modify this code litle bit then same issue comes up i.e. when i send this message programatically. then it not get sent and cross sign appers in front of message in messagelist screen.

//create a multipart Multipart mp = new Multipart(); //data for the content of the file String fileData = "<html>just a simple test</html>"; String messageData = "Mail Attachment Demo"; //create the file SupportedAttachmentPart sap = new SupportedAttachmentPart(mp,"text/html","file.html",fileData.getBytes()); TextBodyPart tbp = new TextBodyPart(mp,messageData); //create a message in the sent items folder Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.DRAFT); Message message = new Message(folders[0]); //new line added. folders[0].appendMessage(message); // after adding this line. this message status is marked as error[red cross sign] //add recipients to the message and send try { Address toAdd = new Address("email@company.com","my email"); Address toAdds[] = new Address[1]; toAdds[0] = toAdd; message.addRecipients(Message.RecipientType.TO,toAdds); message.setContent(mp); Transport.send(message); } catch (Exception e) { Dialog.inform(e.toString()); }

 

i have tried with above statement becuase in our application we are saving messages in folder and after processing the message we are sending them from background thread.

My Question :
1: by adding messaging in a folder. why message is not send properly?
2: is this blackberry OS bug or OS version specific bug?
3: message.getContent() always return TextBodypart even if it contains attachment. AFAIK, it should return Multipart if message contains attachment.  So, my question is this a bug?

Can anyone help me on this.

Thanks in advance.
Regards,
Vijay Saini.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
New Developer
Posts: 72
Registered: ‎08-28-2008
My Device: Not Specified

Re: SupportedAttachmentPart ??

Sorry,few lines is missing in above code. please find full code below

 

//create a multipart Multipart mp = new Multipart(); //data for the content of the file String fileData = "<html>just a simple test</html>"; String messageData = "Mail Attachment Demo"; //create the file SupportedAttachmentPart sap = new SupportedAttachmentPart(mp,"text/html","file.html",fileData.getBytes()); TextBodyPart tbp = new TextBodyPart(mp,messageData); //add the file to the multipart mp.addBodyPart(tbp); mp.addBodyPart(sap); //create a message in the sent items folder Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.DRAFT); Message message = new Message(folders[0]); //new line added. folders[0].appendMessage(message); // after adding this line. this message status is marked as error[red cross sign] //add recipients to the message and send try { Address toAdd = new Address("email@company.com","my email"); Address toAdds[] = new Address[1]; toAdds[0] = toAdd; message.addRecipients(Message.RecipientType.TO,toAdds); message.setContent(mp); Transport.send(message); } catch (Exception e) { Dialog.inform(e.toString()); }

 

 

 

Regards,
Vijay Saini.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
BlackBerry Development Advisor
Posts: 15,136
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: SupportedAttachmentPart ??

What BlackBerry Smartphone model and BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.  Are you testing in the BlackBerry Simulator?  If so, can you send email messages from the messages application?  Open the message with the red X, scroll to the top and post the message status you see.
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
New Developer
Posts: 72
Registered: ‎08-28-2008
My Device: Not Specified

Re: SupportedAttachmentPart ??

Hi

 

i am testing above sample code on real device with following environment.

blackberry 8820

v4.5.0.37(platform 2.7.0.55).

 

i have tried the same code on bold and i am getting same issue. on bold as well.

 

Thanks in advance

 

 

 

 

 

Regards,
Vijay Saini.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
BlackBerry Development Advisor
Posts: 15,136
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: SupportedAttachmentPart ??

I haven't been able to reproduce this.  How large is your attachment?  What message services are configured on the BlackBerry handhelds?  What is the default message service set to?  You can see this by going to Options. Advanced Options, Default Services.
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
New Developer
Posts: 72
Registered: ‎08-28-2008
My Device: Not Specified

Re: SupportedAttachmentPart ??

Hi Msohm,

 

Two message service is confiqured on my device as mentioned below

1: vijay.saini@dbydx.com

2: Desktop account (BES email account)

 

first email is set as default. And i am try to send audio(.amr) file of less than 60 kB as an attachment.

 

Just to inform, i am testing on devices that are locked with Airtel(Bharti telcom, india).  And same code is running fine in Verizon. i don't know whether this issue have any releation with network type(CDMA or GPRS).h

 

Thanks in advance.

 

 

 

 

Regards,
Vijay Saini.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
BlackBerry Development Advisor
Posts: 15,136
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: SupportedAttachmentPart ??

What is the message status for the X'ed out messages?  You can see this by opening the message and scrolling to the top of the screen.

 

Try changing the default service to your BlackBerry Enterprise Server account, perform a hard reset (pull the battery) and try running your application again.  Is it able to send?

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
New Developer
Posts: 72
Registered: ‎08-28-2008
My Device: Not Specified

Re: SupportedAttachmentPart ??

Hi Mshom,

 

I am getting message status as "Error". i had tried after changing my deafult email service to BES one. but still i am getting the same issue.

 

please try to reproduce from your end if possible.

 

Thanks in advance

 

Regards,
Vijay Saini.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish