Package examples.mail

Class IMAPImportMbox

java.lang.Object
examples.mail.IMAPImportMbox

public final class IMAPImportMbox extends Object
This is an example program demonstrating how to use the IMAP[S]Client class. This program connects to a IMAP[S] server and imports messages into the folder from an mbox file.

Usage: IMAPImportMbox imap[s]://user:password@host[:port]/folder/path [selectors]

An example selector might be:

  • 1,2,3,7-10
  • -142986- : this is useful for retrieving messages by apmail number, which appears as From xyz-return-142986-apmail-...

For example:
IMAPImportMbox imaps://user:pass@imap.googlemail.com/imported_messages 201401.mbox 1-10,20 -142986-

  • Field Details

  • Constructor Details

    • IMAPImportMbox

      public IMAPImportMbox()
  • Method Details

    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException
    • startsWith

      private static boolean startsWith(String input, Pattern pat)
    • process

      private static boolean process(StringBuilder sb, IMAPClient imap, String folder, int msgNum) throws IOException
      Throws:
      IOException
    • wanted

      private static boolean wanted(int msgNum, String line, BitSet msgNums, List<String> contains)
      Is the message wanted?
      Parameters:
      msgNum - the message number
      line - the From line
      msgNums - the list of wanted message numbers
      contains - the list of strings to be contained
      Returns:
      true if the message is wanted
    • listContains

      private static boolean listContains(List<String> contains, String string)
      Is at least one entry in the list contained in the string?
      Parameters:
      contains - the list of strings to look for
      string - the String to check against
      Returns:
      true if at least one entry in the contains list is contained in the string