Notify a BlackBerry device application that an email message is about to be sent
- Import the required classes and interfaces.
import net.rim.blackberry.api.mail.NoSuchServiceException;
import net.rim.blackberry.api.mail.SendListener;
import net.rim.blackberry.api.mail.Session;
import net.rim.blackberry.api.mail.Store;
- Implement the SendListener interface.
public class MailSendListener implements SendListener{...}
- Create an instance of the class that implements the SendListener interface.
MailSendListener mailSL = new mailSendListener();
- In a try block, invoke Session.waitForDefaultSession().getStore() to retrieve the Store object.
try
{
Store store = Session.waitForDefaultSession().getStore();
}
- In a catch block, manage a NoSuchServiceException.
catch (NoSuchServiceException e)
{
System.out.println(e.toString());
}
- Invoke Store.addSendListener(MailSendListener) to add a SendListener instance.
store.addSendListener(mailSL);
Was this information helpful? Send us your comments.