Usuwanie wiadomości z poczty.

0

Znalazłem fajny kod..

public void receive(String popServer, String popUser, String popPassword)
  {
    Store store=null;
    Folder folder=null;
    try
    {
      // -- Get hold of the default session --
      Properties props = System.getProperties();
      Session session = Session.getDefaultInstance(props, null);
      // -- Get hold of a POP3 message store, and connect to it --
      store = session.getStore("pop3");
      store.connect(popServer, popUser, popPassword);

      // -- Try to get hold of the default folder --
      folder = store.getDefaultFolder();
      if (folder == null) throw new Exception("No default folder");
      // -- ...and its INBOX --
      folder = folder.getFolder("INBOX");
      if (folder == null) throw new Exception("No POP3 INBOX");
      // -- Open the folder for read only --
      folder.open(Folder.READ_WRITE);
      // -- Get the message wrappers and process them --
      Message[] msgs = folder.getMessages();
     // wyswietlamy tylko jedna pierwsza wiadomosc (wariant ponizej wyswietla wszystkie)
      //printMessage(msgs[0]);

     for (int msgNum = 0; msgNum < msgs.length; msgNum++)
       {
        printMessage(msgs[msgNum]);
       }

    } catch (Exception ex) { ex.printStackTrace(); }

    finally
    {
      // -- Close down nicely --
      try
      {
        if (folder!=null) folder.close(false);
        if (store!=null) store.close();
      }
      catch (Exception ex2) {ex2.printStackTrace();}
    }
  }

Wstawiłem do programu nawet działa ;)
Znalazłem tez opis autora doku który przeczytałme, niestety nic nie napisał odnośnie ort! wiadomośći ;/
Jak usunąć przeczytana juz wiadomość?

Kombinowałem coś z czyszczeniem foldera ale bez sukcesu ;/

msgs[msgNum].setFlag(Flags.Flag.DELETED, true);

Juz znalazlem, przepraszam za klopot ;)

Jednak mój serwer pocztowy nie obsługuje tej komendy, macie może inne pomysły?

0

Zmień pocztę :D

0
Patryk27 napisał(a)

Zmień pocztę :D

Zmień forum.

1 użytkowników online, w tym zalogowanych: 0, gości: 1