Class IMAPExportMbox
- java.lang.Object
-
- org.apache.commons.net.examples.mail.IMAPExportMbox
-
public final class IMAPExportMbox extends java.lang.Object
This is an example program demonstrating how to use the IMAP[S]Client class. This program connects to a IMAP[S] server and exports selected messages from a folder into an mbox file.Usage: IMAPExportMbox imap[s]://user:password@host[:port]/folder/path
[sequence-set] [item-names] An example sequence-set might be:
- 11,2,3:10,20:*
- 1:* - this is the default
Some example item-names might be:
- BODY.PEEK[HEADER]
- 'BODY.PEEK[HEADER.FIELDS (SUBJECT)]'
- ALL - macro equivalent to '(FLAGS INTERNALDATE RFC822.SIZE ENVELOPE)'
- FAST - macro equivalent to '(FLAGS INTERNALDATE RFC822.SIZE)'
- FULL - macro equivalent to '(FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)'
- ENVELOPE X-GM-LABELS
- '(INTERNALDATE BODY.PEEK[])' - this is the default
Macro names cannot be combined with anything else; they must be used alone.
Note that using BODY will set the \Seen flag. This is why the default uses BODY.PEEK[].
The item name X-GM-LABELS is a Google Mail extension; it shows the labels for a message.
For example:
IMAPExportMbox imaps://username:password@imap.googlemail.com/messages_for_export exported.mbox 1:10,20
IMAPExportMbox imaps://username:password@imap.googlemail.com/messages_for_export exported.mbox 3 ENVELOPE X-GM-LABELS
The sequence-set is passed unmodified to the FETCH command.
The item names are wrapped in parentheses if more than one is provided. Otherwise, the parameter is assumed to be wrapped if necessary.
Parameters with spaces must be quoted otherwise the OS shell will normally treat them as separate parameters.
Also the listener that writes the mailbox only captures the multi-line responses (e.g. ones that include BODY references). It does not capture the output from FETCH commands using item names such as ENVELOPE or FLAGS that return a single line response.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
IMAPExportMbox.MboxListener
-
Field Summary
Fields Modifier and Type Field Description private static int
CONNECT_TIMEOUT
private static java.lang.String
CRLF
private static java.lang.String
EOL_DEFAULT
private static java.lang.String
LF
private static java.util.regex.Pattern
PATEXISTS
private static java.util.regex.Pattern
PATFROM
private static java.util.regex.Pattern
PATID
private static int
PATID_DATE_GROUP
private static java.util.regex.Pattern
PATSEQ
private static int
PATSEQ_SEQUENCE_GROUP
private static java.util.regex.Pattern
PATTEMPFAIL
private static int
READ_TIMEOUT
-
Constructor Summary
Constructors Constructor Description IMAPExportMbox()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
private static java.lang.String
matches(java.lang.String input, java.util.regex.Pattern pat, int index)
private static boolean
startsWith(java.lang.String input, java.util.regex.Pattern pat)
-
-
-
Field Detail
-
CRLF
private static final java.lang.String CRLF
- See Also:
- Constant Field Values
-
LF
private static final java.lang.String LF
- See Also:
- Constant Field Values
-
EOL_DEFAULT
private static final java.lang.String EOL_DEFAULT
-
PATFROM
private static final java.util.regex.Pattern PATFROM
-
PATID
private static final java.util.regex.Pattern PATID
-
PATID_DATE_GROUP
private static final int PATID_DATE_GROUP
- See Also:
- Constant Field Values
-
PATSEQ
private static final java.util.regex.Pattern PATSEQ
-
PATSEQ_SEQUENCE_GROUP
private static final int PATSEQ_SEQUENCE_GROUP
- See Also:
- Constant Field Values
-
PATEXISTS
private static final java.util.regex.Pattern PATEXISTS
-
PATTEMPFAIL
private static final java.util.regex.Pattern PATTEMPFAIL
-
CONNECT_TIMEOUT
private static final int CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
READ_TIMEOUT
private static final int READ_TIMEOUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.io.IOException, java.net.URISyntaxException
- Throws:
java.io.IOException
java.net.URISyntaxException
-
matches
private static java.lang.String matches(java.lang.String input, java.util.regex.Pattern pat, int index)
-
startsWith
private static boolean startsWith(java.lang.String input, java.util.regex.Pattern pat)
-
-