BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-26-2010, 08:50 PM   #1 (permalink)
New Member
 
Join Date: Oct 2010
Model: 9700
PIN: N/A
Carrier: IT
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Email send status is "GENERAL SEND FAILURE" or "PENDING"

Please Login to Remove!

I am facing a problem about the send email with attachment for Blackberry Application

The coding i done already, and also can send...
when i check at the outbox, my email status is become "GENERAL SEND FAILURE" or "Pending". Always cannot send successfully.
what happend? for the original button that provide by blackberry can sent successfully, only the new buttom i added which to function to retrieve all the image from folder then send by email but not success... the status always "GENERAL SEND FAILURE" or "pending"
anyone have the idea? is it i miss something to add in the code? or the setting?

HERE is the code



String root="file:///store/home/user/pictures/";
FileConnection fc1 = null;
Enumeration rootEnum = null;
Vector elementData = new Vector();
Multipart mp = new Multipart();
if (root != null)
{
// Open the file system and get the list of directories/files
try
{
fc1 = (FileConnection)Connector.open(root);
rootEnum = fc1.list();

//Vector elementData = new Vector();
while( rootEnum.hasMoreElements() ){
elementData.addElement(rootEnum.nextElement());


}
//int elementCount = elementData.size();
//String first = (String) elementData.elementAt(0);

}
catch (Exception e)
{
return;
}
finally
{
if (fc1 != null)
{
try
{
fc1.close();
fc1 = null;
}
catch (IOException e)
{
}
}
}
}


int elementCount = elementData.size();
int IMAGEFilterCount=0;
String TempfileName;
String[] myarray = new String[1000];


// String[] strArray = null;


try {
for (int k = 0; k < elementCount; k++)
{

String IMAGEARRAY = (String) elementData.elementAt(k);
String filePathCLOSE = "file:///store/home/user/pictures/" + IMAGEARRAY;
FileConnection fconn = (FileConnection)Connector.open(filePathCLOSE);


if(fconn.exists())
{

if(IMAGEARRAY.startsWith("IMG"))
{
fconn.rename("FEDEX_" + IMAGEARRAY);

myarray[IMAGEFilterCount] = fconn.getName();

IMAGEFilterCount++;
}

fconn.close();
}
}
} catch (IOException e) {
e.printStackTrace();
e.getMessage(); //tell me what this says
}




ExtendedFileConnection fc = null;
InputStream fis = null;
byte imageData[] = null;
try{

for (int i = 0; i < IMAGEFilterCount; i++)
{

String filtername = myarray[i];

// String IMAGEARRAY = (String) elementData.elementAt(i);

// String filePath = "file:///store/home/user/pictures/" + IMAGEARRAY;
String filePath = "file:///store/home/user/pictures/" + filtername;

fc = (ExtendedFileConnection) Connector.open(filePath, Connector.READ);

if(fc.exists()){



fis = fc.openRawInputStream();
// int len = (int) fc.rawFileSize();
int len = (int)fc.fileSize();
//data = new byte[fileSize];
imageData = new byte[len];
// int length = fis.read(imageData, 0, len);

SupportedAttachmentPart sap = new
//SupportedAttachmentPart(mp,"image/jpeg",filtername, imageData);
SupportedAttachmentPart(mp,MIMETypeAssociations.ge tMIMEType(filtername),filtername, imageData);
mp.addBodyPart(sap);
}
}
}catch(OutOfMemoryError error){
System.gc();
//in case of out of memory error replace with dummyImage
System.out.println("Out of Memory Exception in creating Image: "+error.getMessage());
}catch(Exception e){
System.gc();
System.out.println("Exception in reading file data: "+e.getMessage());
e.printStackTrace();
}finally{
try{
fc.close();
System.out.println("FileConnection closed successfully");
}catch(Exception e){
System.out.println("Error while closing file Connection"+e.getMessage());
}
}

Store store = Session.getDefaultInstance().getStore();
Folder[] folders = store.list(Folder.SENT);
Folder sentfolder = folders[0];
// Create message.
Message msg = new Message(sentfolder);
// Add TO Recipients.
Address toList[] = new Address[1];
try {
toList[0]= new Address("CEO@Google123.com", "Bill Gates");
} catch(AddressException e) {
System.out.println(e.toString());


}
try {
msg.addRecipients(Message.RecipientType.TO, toList);
} catch (MessagingException e) {
System.out.println(e.toString());
}
// Add CC Recipients.
Address ccList[] = new Address[1];
try {
ccList[0]= new Address("COO@Google123.com", "Bill Gates Wife");
} catch(AddressException e) {
System.out.println(e.toString());
}
try {
msg.addRecipients(Message.RecipientType.CC, ccList);
} catch (MessagingException e) {
System.out.println(e.toString());
}
// Add the subject.
msg.setSubject("Google Image");
// Add the message body.
try {
msg.setContent(mp);
} catch(MessagingException e) {
// Handle messaging exceptions.
}
// Send the message.
try {
Transport.send(msg);
} catch(MessagingException e) {
System.out.println(e.getMessage());
}
System.out.println("Email sent successfully.");

//FileConnection fconn;
try {
for (int j = 0; j < IMAGEFilterCount; j++)
{

String filtername = myarray[j];

String filePathCLOSE = "file:///store/home/user/pictures/" + filtername;


FileConnection fconn = (FileConnection)Connector.open(filePathCLOSE);

if(fconn.exists()){
fconn.delete();
fconn.close();
}}
} catch (IOException e) {
e.printStackTrace();
e.getMessage(); //tell me what this says
}
System.exit(0);
Offline  
Old 10-26-2010, 10:02 PM   #2 (permalink)
New Member
 
Join Date: Oct 2010
Model: 9700
PIN: N/A
Carrier: IT
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

anyone can help me? just talk something!...

please, it is urgent!!! so nervous now....
Offline  
Old 10-26-2010, 10:53 PM   #3 (permalink)
New Member
 
Join Date: Oct 2010
Model: 9700
PIN: N/A
Carrier: IT
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

solved!!!
just remove --> System.exit(0);

System.exit(0) is typically a whole lot more than go out from a screen. System.exit(0) typically shuts down the whole JVM. Maybe it's different for this specific case though.
Offline  
Old 10-28-2010, 03:46 PM   #4 (permalink)
New Member
 
Join Date: Jul 2010
Model: 9700
PIN: N/A
Carrier: Verizon
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Not typically

No it doesn't typically shut down the JVM, it always causes your program and all subsequent threads as well as the JVM to terminate. This is also even if they were already in the middle of doing something. The only time you should ever call System.exit() is when the user closes the application and after you have had time to clean up any loose ends (and even then it is typically unnecessary).
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.