Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

JavaMail

Thread view: 
alex.korsak@gmail.com - 18 Jul 2007 17:34 GMT
I didn't find some information: how can i remove message from mail.
source:

Properties properties = System.getProperties();

        Session session = Session.getInstance(properties, null);
        try {
            Store store = session.getStore("imap");
            store.connect("imap.mail.ru","*******","******");
            Folder inbox = store.getDefaultFolder();
            inbox = inbox.getFolder("INBOX");

            inbox.open(Folder.READ_WRITE);
            int count = inbox.getMessageCount();
            System.out.println("Number of mails is " + count);
            for (int i = 1; i <= count; i++) {
                Message message = inbox.getMessage(i);
                String subject = message.getSubject();
                if (subject.toLowerCase().indexOf("c++") != -1) {
                    System.out.println(message.getSubject());
                                       // there remove message
                }    // end if
            }    // end for

            inbox.close(true);
            store.close();
        } catch (NoSuchProviderException e) {
            e.printStackTrace();
        } catch (MessagingException e) {
            e.printStackTrace();
        }    // end try
Juan Singh - 18 Jul 2007 17:41 GMT
Refer to Folder.setFlag() method. You have to set the flag of all
desired messages to DELETED.

> I didn't find some information: how can i remove message from mail.
> source:
[quoted text clipped - 27 lines]
>             e.printStackTrace();
>         }    // end try
Eric Sosman - 18 Jul 2007 17:44 GMT
alex.korsak@gmail.com wrote On 07/18/07 12:34,:
> I didn't find some information: how can i remove message from mail.
> source:
> [... snipped; see up-thread ...]

   Call

    message.setFlag(Flag.DELETED, true);

... to mark a message for deletion.  All the marked
messages will be deleted later, when you call

    inbox.close(true);

Signature

Eric.Sosman@sun.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.