Summary
This article applies to the following:
|
|||||||||||||||||||||
Description
There are two methods that can be used to access email attachments in a BlackBerry Java Application. The first method is to create a custom attachment handler. This is supported in BlackBerry® Device Software 3.6 and later. The second method is to create a content handler using the Java Specification Request (JSR) 175 Content Handler.
AttachmentDownloadManager
The AttachmentDownloadManager class was added in version 5.0 of the BlackBerry API set. This class provides the ability to prgrammatically download email attachments for incoming message. It does not support forwarded or sent messages. Attachments can be downloaded regardless of its viewable state. That is, an attachment can be of type SupportedAttachmentPart or UnsupportedAttachmentPart. You can implement DownloadProgressListener to receive downloading outcomes.
JSR 175 Content Handler
Support for JSR 175 Content Handler application programming interfaces (APIs) was introduced with BlackBerry Device Software 4.5. To use these APIs, the BlackBerry smartphone must be running BlackBerry Device Software 4.5 or later. Once an application is registered as a content handler for a specific file, the BlackBerry smartphone user sees a Download Now menu option when they view an email message with an attachment (and the attachment file type matches the registered content handler). The BlackBerry smartphone user can select this menu option to download the attachment, which is then supplied to the application. For an example, see the
Custom Attachment Handler
You can create an application to have the BlackBerry smartphone process a specific attachment type, or deliver data to a BlackBerry smartphone application as an email attachment.
By default, email attachments are not delivered or stored on the BlackBerry smartphone. To force an email attachment to be sent or stored on the BlackBerry smartphone, add the prefix x-rimdevice to the attachment name.
Note: Secure Multipurpose Internet Mail Extensions (S/MIME) attachments are not delivered to the BlackBerry smartphone, regardless of whether they have the x-rimdevice prefix.
Maximum attachment size for x-rimdevice attachments
For BlackBerry smartphones running BlackBerry Device Software 4.0, the 64 KB maximum size limit includes the attachment, message headers, and the message body. Therefore, the attachment size should be lower than 59 KB. Attachments larger than this are partially delivered to the BlackBerry smartphone. The files are truncated at the maximum size.
The following code sample shows how to create an Attachment Handler on the BlackBerry smartphone. This application adds a View File menu option when the BlackBerry smartphone user views an email message that contains a Wireless Markup Language (WML) file attachment.
/*
|