BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 03-02-2010, 05:23 AM   #1 (permalink)
New Member
Join Date: Mar 2010
Model: 7100T
Carrier: EES
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb cannot send image greater than 64KB

Please Login to Remove!

Hello everyone,

I am new to blackberry and i want to send an image through mail which is around 432KB large.But i am unable to do it.Can anyone help

Here is my code:

class SendEmail extends Thread
boolean bCanSend = false;
Store msgStore;
Folder[] folderList;
Folder outFolder;
Message msg;
Transport emailTransport;
String _emailTo,_emailBody;
Multipart mp ;
String str="Heart.png";
byte[] imgData;
private Bitmap image;
SupportedAttachmentPart sap;

String messageData = "Mail Attachment Demo";

SendEmail(String emailTo,String emailBody)
Session s = Session.getDefaultInstance();
image = Bitmap.getBitmapResource("Heart.png");
imgData = getBytesFromBitmap(image);
System.out.println("trying to create session");
mp = new Multipart();

if(s == null)
String errMsg = "Unabled to send email message.\n";
bCanSend = false;

System.out.println(" created session");
bCanSend = true;
sap = new SupportedAttachmentPart(mp, "image/bmp","Heart.bmp",imgData);
TextBodyPart tbp = new TextBodyPart(mp,messageData);

//add the file to the multipart

_emailTo = emailTo;
_emailBody = emailBody;
System.out.println("Body part added");
emailTransport = Session.waitForDefaultSession().getTransport();
msgStore = Session.waitForDefaultSession().getStore();
folderList = msgStore.list(Folder.SENT);
outFolder = folderList[0];
msg = new Message(outFolder);
System.out.println(" session method end");

catch(NoSuchServiceException nse)


public byte[] getBytesFromBitmap(Bitmap bmp)
try {

System.out.println("converting bitmap");
int height=bmp.getHeight();
int width=bmp.getWidth();
int[] rgbdata = new int[width*height];
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
Graphics g = new Graphics(bmp);
for (int i = 0; i < rgbdata.length ; i++) {
if (rgbdata[i] != -1)
return bos.toByteArray();
catch (Exception ex)
Dialog.alert("getBytesFromBitmap: " + ex.toString()); return null; }

public void run()
System.out.println("SendEmail :: running");
if(bCanSend == true)
Address [] addresses = new Address[1];
addresses[0] = new Address(_emailTo, _emailTo);
msg.addRecipients(Message.RecipientType.TO, addresses);
msg.setSubject("IBM Calendar Share!");
System.out.println("Email has been sent");
catch(Exception e)
System.out.println("Exception caught trying to send email: " +

I know that SupportedAttachmentPart cannot send or receive more than 64KB but i found no other way for attachment. need this for project.This is urgent.Please help

Thanks in advance
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
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.