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

Capture the contents of email and PIN messages before sending

by Retired ‎02-16-2010 12:57 PM - edited ‎02-17-2010 03:52 PM (2,269 Views)


This article applies to the following:

  • BlackBerry® Device Software 4.1 and later
  • BlackBerry® Java® Development Environment (JDE) 4.1 and later


The net.rim.blackberry.api.mail.SendListener interface was introduced in BlackBerry JDE 4.1 and allows an application to capture both personal identification number (PIN) and email messages before they are added to the queue for sending.

If the method returns a result of false, the message will not be sent and an X will be displayed beside the message in the BlackBerry device message list. If the method returns a result of true, this will indicate that the message should be queued for sending.

The following example shows how to use SendListener:

public class MyEmailChecker extends Application{
MySendListener myListener;
Store store;
public static void main(String[] args){
new MyEmailChecker().enterEventDispatcher();
private MyEmailChecker(){
Session session = Session.getDefaultInstance();
if (session==null){
System.out.println("Session is null");
else {
store = session.getStore();
myListener = new MySendListener();

public class MySendListener implements SendListener {
//sendMessage is invoked just before the message is queued for sending
public boolean sendMessage(Message message){
if (message.getSubject().equals("keyword")){
//do some processing on the message
return true;

Users Online
Currently online: 15 members 2,727 guests
Please welcome our newest community members: