BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-08-2008, 02:40 AM   #1 (permalink)
New Member
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: SMART
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb File creation

Please Login to Remove!

does anyone able to create a file in BB using Java? I need to create a temporary file so that I can attach a message(from the inbox) to an email that im about to send.

Thanks
Offline  
Old 04-08-2008, 04:43 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: IT
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hope I got your point:

In order to create a file on BB you can use the FileConnection Class.

CU Happe

P.S.: I just saw your question on "my" Thread, there you find more information ;)

Last edited by Happe79 : 04-08-2008 at 04:45 AM.
Offline  
Old 04-08-2008, 07:22 AM   #3 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

if you don't intend to end your application in between you don't need to save the file to disk, you can just hold it in memory as a byte-array or similar.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 04-08-2008, 08:37 PM   #4 (permalink)
New Member
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: SMART
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

what i need to do is to create a custom application to create and send emails. part of this is to be able to attach some files(either a message from the inbox, call logs, contacts, an image file in the SD card). My colleagues suggested that I will read the messages from the inbox, create a file from those messages and attach the created file to the email itself. I will try the code suggested by Happe79. Another requirement is to be able to browse through the folders and manually select the file to be attached.

Thank you for the help.
Offline  
Old 04-09-2008, 01:17 AM   #5 (permalink)
New Member
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: SMART
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

just a quick question.. how can i identify what i will put in the content type here:

SupportedAttachmentPart attachPart =
new SupportedAttachmentPart(multipart, contentType,
fileName, readFile(fileName));

I've tried to use: "image/jpeg" (i know that what im attaching is a jpg file). but the attachment cannot be viewed.
Offline  
Old 04-09-2008, 01:50 AM   #6 (permalink)
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Join Date: Oct 2007
Location: Seattle, WA
Model: 9020
PIN: N/A
Carrier: T-Mobile
Posts: 212
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You just have to know what you're attaching. Whenever I'm not sure of the MIME type of a file extension I'll usually either Google it or check the "mime.types" file in my Apache config dir. Eg:

Code:
image/jpeg                      jpeg jpg jpe
So it seems as if your mime type is accurate. The problem is most likely somewhere else. I assume your readFile method returns a byte[]? Have you tried using a png image (or just a simple text email) instead? Work on getting a baseline.

BTW, you don't need to create any temporary files - just cache your content in memory.
__________________
Do your homework and know how to ask a good question.
Offline  
Old 04-09-2008, 02:34 AM   #7 (permalink)
New Member
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: SMART
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

@richard.puckett

yes, the readFile method returns byte[]. I've used the code suggested by pa4o85. I've used image/jpeg as the content type. but to no avail.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.