MailSearch

MailSearch[folder,assoc]

searches the specified mail folder for messages with properties matching elements in assoc.

MailSearch[assoc]

searches the current default mail inbox.

MailSearch[]

gives the list of unread messages in the current default mail inbox.

Details and Options

  • MailSearch[] does not include messages that have been marked for deletion.
  • Mail folders are specified as follows:
  • MailFolder[]a single mail folder
    {MailFolder[],}list of mail folders
    MailServerConnection[]all mail folders for a particular mail server connection
  • The current default mail inbox is as specified in $IncomingMailSettings.
  • Basic search keys to use in assoc include:
  • "From"message sender
    "To"message addressee(s)
    "Cc"recipients copied on the message
    "Bcc"recipients blind-copied on the message
  • Date-related search keys include:
  • "SentBefore"messages sent before the specified date
    "SentOn"messages sent on the specified date
    "SentAfter"messages sent after the specified date
  • Size-related search keys include:
  • "SizeLessThan"messages smaller than the specified byte size
    "SizeGreaterThan"messages larger than the specified byte size
  • Metadata-related keys include:
  • "Flags"protocol-defined flags (e.g. "Answered", "Flagged", "Draft", )
    "Tags"user-defined tags
  • Other keys include:
  • "Body"full text search for the message body
    "Text"full text search for any field
  • Keys such as "To" can have values in which separate items are either given in a list or as parts of a string separated by commas.
  • MailSearch has the following options:
  • MaxItemsAutomaticmaximum number of mail items to return
    TimeConstraintAutomatictime constraint for retrieving mail items
  • With the setting TimeConstraint->Automatic, MailSearch running with a notebook front end will typically terminate with a message if the time constraint is exceeded. It will keep going if there is no notebook front end.

Examples

open allclose all

Basic Examples  (1)

Connect to the configured mail server:

Open the "Example" folder:

Search for messages received since yesterday:

Get individual complete mail items:

Options  (2)

MaxItems  (1)

Connect to a server:

Open the "Junk" folder:

Search for a common term in junk emails:

Limit the results to 10 items:

TimeConstraint  (1)

Connect to a server:

Open the "Junk" folder:

Search for a common term in junk emails:

Limit the search to 0.25 second:

Neat Examples  (1)

Connect to a server:

Open the "Junk" folder:

Search for unread messages and return the sender:

Find the number of messages from the most prolific email sender:

Make a histogram of the distribution of the number of emails sent by the sender:

Introduced in 2018
 (11.3)