Welcome!

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

Reply
Developer
Posts: 99
Registered: ‎03-10-2009
My Device: Not Specified
Accepted Solution

How can be not logged when sending an email in blackberry

hi,

 

I need to send some emails by the method Transport.send(), but I find this will be logged.

 

And, since there will be a lot of mails a day, there are too many logs in the sent mails.

 

 How can it not be shown in the [sent mails/items] ?

 

Thanks,

Jerry

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How can be not logged when sending an email in blackberry

You could delete the message after it has been sent.  This removes it from the sent items folder/list.
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
Developer
Posts: 99
Registered: ‎03-10-2009
My Device: Not Specified

Re: How can be not logged when sending an email in blackberry

HI, THANKS.

 

Do you mean I can delete the sent log in the sent item manually?

 

Can you please give a simple example ?

 

I find the class Folder, and the SENT field, but I don't know how to use them.

 

Thanks.

Developer
Posts: 99
Registered: ‎03-10-2009
My Device: Not Specified

Re: How can be not logged when sending an email in blackberry

It is so weird. I am trying to send the message first then delete it from the sent box. It works fine on simulator but when I upload it on to the handheld (curve), it doesn't send the message out. And the message is not there in the sent box (it has been deleted.).

When I comment off the deleting function codes, it sends the message out.

Can anybody give some suggestions ? Thanks.


My code is like following:


Message msg = new Message(sentfolder);

msg.setSubject(...);

msg.setContent(...);


try {

Transport.send(msg);

} catch(MessagingException e) {
System.out.println(e.getMessage());
}



// delete the sent log in the sent box

msg.setFlag(Message.Flag.OPENED, true);
Folder folder = msg.getFolder();
boolean bRet = folder.deleteMessage(msg,true);
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How can be not logged when sending an email in blackberry

Don't delete the message immediately, give some time and try deleting it.

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 99
Registered: ‎03-10-2009
My Device: Not Specified

Re: How can be not logged when sending an email in blackberry

I add a sleeping time between sending and deleting. But it seems the mail still cannot be sent.

 

Anymore suggestions ? Thanks. 

 

// sending here 

...

        

// sleeping 

try{

         

            Thread.sleep(2000);

         

        }catch(InterruptedException e)

        {

            System.out.println(e.getMessage());

        }

        

        // delete the sent log in the sent box

 

        msg.setFlag(Message.Flag.OPENED, true);

        Folder folder = msg.getFolder();

        boolean bRet = folder.deleteMessage(msg,true); 

Highlighted
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How can be not logged when sending an email in blackberry

Before deleting the message make sure that the Message.Status of the Message has changed to TX_SENT, indicating that it was sent.
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