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
Developer
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Deleting all email Programatically

How to deleting all emails programatically?

Thanks in advance

Developer
Posts: 16,985
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Deleting all email Programatically

enter 'delete mail' in the search field and check the numerous results.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: Deleting all email Programatically

i have search and didnot get the code which worked correctly in OS 6 or OS7

for deleting all mail programatically

Developer
Posts: 16,985
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Deleting all email Programatically

and what kind of help do you expect now that you have given such a detailed description of your issue?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: Deleting all email Programatically

i have use this code

public void wiperFolder()
{
ServiceBook sb = ServiceBook.getSB();
ServiceRecord[] srs = sb.getRecords();
String msg="";
for(int cnt = srs.length - 1; cnt >= 0; --cnt)
{
if( srs[cnt].getCid().equals( "CMIME" ))
{
ServiceConfiguration sc = new ServiceConfiguration(srs[cnt]);
try
{
Store store = Session.getInstance(sc).getStore();
Folder[] folders = store.list();
int nFolders = folders.length;
for(int i=0; i<nFolders; i++)
{
Folder fFolder = folders[i];
Message message = new Message(fFolder);
fFolder.deleteMessage(message);
// System.out.println(message+"-------wiperFolder-----1---"+fFolder);
}

}
catch (Exception e)
{
System.out.println(e.toString());
}
}
}

}

to wipe all the messages include TextMessage and Email

but not working ...

public void deleteSendMail()
{
Store store=null;

try {
store = Session.waitForDefaultSession().getStore();
} catch (NoSuchServiceException e) {
System.out.println(e.toString());
}

Folder[] folders = store.list(Folder.SENT);
Folder sentfolder = folders[0];
Message msg[] = null;
try {
msg=sentfolder.getMessages();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int count =msg.length;
for(int j=0;j<count;j++)
{
Message m=msg[j];
sentfolder.deleteMessage(m,true);
}



}

 

It does not work in OS 6 or OS 7 device.................

 

also seperately i have also used to delete all send mail but also it doesnot work..

 

 

 

 

 

Developer
Posts: 16,985
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Deleting all email Programatically

please use the code tag to format code.

what is the reason behind creating a new message object and then deleting it? "Message message = new Message(fFolder);"
did you debug your code and checked the count etc?

you won't be able to delete any text messages as there is no API for that.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: Deleting all email Programatically

Yes in respect of second code i have done that count............please can u helpe where i am wrong....