Notify a BlackBerry device application that an email message is about to be sent

  1. 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;
    
  2. Implement the SendListener interface.
    public class MailSendListener implements SendListener{...}
  3. Create an instance of the class that implements the SendListener interface.
    MailSendListener mailSL = new mailSendListener();
  4. In a try block, invoke Session.waitForDefaultSession().getStore() to retrieve the Store object.
    try 
    {
       Store store = Session.waitForDefaultSession().getStore();
    }
  5. In a catch block, manage a NoSuchServiceException.
    catch (NoSuchServiceException e) 
    {
       System.out.println(e.toString());
    }
  6. Invoke Store.addSendListener(MailSendListener) to add a SendListener instance.
    store.addSendListener(mailSL);

Was this information helpful? Send us your comments.