01-29-2009 11:41 PM
IDE: Blackberry JDE Version 4.5.0.7
Simulator: About - BlackBerry Smartphone Simulator 2.9.0.52
Model: BlackBerry Curve 8310 smartphone
I have a java program which sends an email to a hardcoded email address every 15 mins. The code it uses is from the Knowledge Centre:
//Get the Store from the default mail Session.
Store store = Session.getDefaultInstance().getStore();
//retrieve the sent folder
Folder[] folders = store.list(Folder.SENT);
Folder sentfolder = folders[0];
//create a new message and store it in the sent folder
Message msg = new Message(sentfolder);
Address recipients[] = new Address[1];
try {
recipients[0]= new Address(“user@company.com”, “user”);
//add the recipient list to the message
msg.addRecipients(Message.RecipientType.TO, recipients);
//set a subject for the message
msg.setSubject(“Test email”);
//sets the body of the message
msg.setContent(“This is a test email from my BlackBerry Wireless Handheld”);
//sets priority
msg.setPriority(Message.Priority.HIGH);
//send the message
Transport.send(msg);
}
catch (Exception me) {
System.err.printIn(me);
}
The code works perfectly. But I need to modify it such that AFTER an email has been sent, the message is deleted from the Sent Folder. How can this be done?
Thanks.
Solved! Go to Solution.
01-30-2009 03:38 AM
02-01-2009 06:23 PM
Thanks for that simon. I'm going to try that now, but could you answer these 2 questions anyway:-
1) What does this line of code achieve - m.setFlag(Message.Flag.OPENED, true);
Setting it to true will mean that the message has been read, but why is that required here?
2) The definition of the deleteMessage method is
deleteMessage(Message msg, boolean forceDeleteSaved)
What's the boolean argument for?
Cheers again.
02-02-2009 03:46 AM
02-02-2009 05:09 PM
04-02-2012 10:13 AM
02-10-2013 09:38 PM - edited 02-10-2013 10:35 PM
Hey Guys,
I'm having similar problem with deleteMessage(). the message is still present in outbox folder on the device after invoking.
Im using Blackberry 9860 device running OS 7.1 to test and Blackberry Java SDK Version 7.1 to build application.
Here is a snippet of the code
Store store = Session.getDefaultInstance().getStore();
Folder [] folders = store.list(Folder.SENT);
Folder sentFolder = folders[0];
Message msg = new Message(sentFolder);
try
{
Address toList[] = new Address[1];
// toList[0] = new Address("r_blakey@msn.com", msg.getFolder().getName());
toList[0] = new Address("name@domain.com", "Rdot");
msg.addRecipients(Message.RecipientType.TO,toList)
msg.setContent("Testing 1 2 3");
Transport.send(msg);
sentFolder.deleteMessage(msg);
Any hint at why the email isnt being deleted from the outbox would be greatly appreciated.
Thanks in advance