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

New Developer
Posts: 19
Registered: ‎07-14-2008
My Device: Not Specified

Send email to Self/Place email in Inbox

[ Edited ]

Hello, I am using the following code to try and place an email in the user's inbox.

    public void sendEmail()
        String emailAddress = getEmailAddress();
        if(emailAddress != null)
            statusFielder.setText(statusFielder.getText() +"\n" +"My email: " +emailAddress);
            //Get the Store from the default mail Session.
            Store store = Session.getDefaultInstance().getStore();

            Folder[] folders = store.list(Folder.INBOX);
            Folder inbox = folders[0];

            Message msg = new Message(inbox);
            Address to[] = new Address[2];

            try {
                to[0]= new Address("Update", "Update"); 
                to[1] = new Address(emailAddress, emailAddress);
                msg.addRecipient(Message.RecipientType.TO, to[1]);
                msg.setSubject("Certificate Expiry");

                msg.setContent("Hello, \n Your certificate is aboot to expire");

                msg.setStatus(Message.Status.RX_RECEIVED, Message.Status.TX_SENT);
                //send the message
            catch (Exception me) {
            statusFielder.setText("No Default Email");
     public static String getEmailAddress() 
        String emailAddress;
        try {
            Session ourSession = Session.getDefaultInstance();
            emailAddress = ourSession.getServiceConfiguration().getEmailAddress();
        } catch ( Exception e ) {
            emailAddress = null;
        return emailAddress;

However this places it in the Outbox as if it were waiting to be sent. How can I make it so it goes to the Inbox instead of Outbox? (Have only tested on simulator)



BlackBerry Development Advisor
Posts: 15,016
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Send email to Self/Place email in Inbox

This should be stored in the Inbox, but it will be a draft message that is ready to be sent.


If you wish to add a custom (non draft) message to the inbox you can use the MessageList APIs.  You can refer to the messagelistdemo that comes with the BlackBerry Java SDK and BlackBerry JDE for an example.


Documentation on this can be found here: http://docs.blackberry.com/en/developers/deliverables/7693/Using_custom_messages_folders_511381_11.j...




Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker