Package examples.mail

Class IMAPExportMbox

java.lang.Object
examples.mail.IMAPExportMbox

public final class IMAPExportMbox 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 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
  • ENVELOPE
  • '(INTERNALDATE BODY.PEEK[])' - this is the default

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

Note that 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. It does not capture the output from ENVELOPE commands.