<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"/> <title>Searching messages</title> <link rel="stylesheet" href="manpage.css" type="text/css"/> <link rel="start" href="index.html" title="Cone: COnsole Newsreader And Emailer"/> <link rel="up" href="smap1.html" title="Appendix A. Simple Mail Access Protocol, Version 1"/> <link rel="prev" href="smapcopymovemessages.html" title="Copying and moving messages"/> <link rel="next" href="smaplogout.html" title="Logging off"/> <link xmlns="" rel="icon" href="icon.gif" type="image/gif"/> <meta xmlns="" name="MSSmartTagsPreventParsing" content="TRUE"/> <!-- Copyright 2002 - 2007 Double Precision, Inc. See COPYING for distribution information. --> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center" rowspan="1">Searching messages</th> </tr> <tr> <td width="20%" align="left" rowspan="1" colspan="1"> <a accesskey="p" href="smapcopymovemessages.html" shape="rect">Prev</a> </td> <th width="60%" align="center" rowspan="1" colspan="1"> Appendix A. Simple Mail Access Protocol, Version 1</th> <td width="20%" align="right" rowspan="1" colspan="1">  <a accesskey="n" href="smaplogout.html" shape="rect">Next</a></td> </tr> </table> <hr/> </div> <div class="section" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="search" shape="rect" name="search"> </a>Searching messages</h3> </div> </div> </div> <div class="literallayout"> <p><br clear="none"/> C: SEARCH MARKED NOT TO "nobody@example.com"<br clear="none"/> S: * SEARCH 1 3-5 7<br clear="none"/> S: +OK Messages searched<br clear="none"/> C: SEARCH 1-5,15-20 LARGER 10000<br clear="none"/> S: * SEARCH 1 3-5 17<br clear="none"/> S: +OK Messages searched<br clear="none"/></p> </div> <p>The <code class="literal">SEARCH</code> command instructs the server to search messages in the currently open folder. The next whitespace delimited word specifies the set of messages to search. The remaining words specify the search criteria. The set of messages to search is specified in one of four ways:</p> <div class="variablelist"> <dl> <dt><span class="term">MARKED</span></dt> <dd> <p>Search only the messages that have the <code class="literal">MARKED</code> flag already set.</p> </dd> <dt><span class="term">UNMARKED</span></dt> <dd> <p>Search only the messages that do not have the <code class="literal">MARKED</code> flag set.</p> </dd> <dt><span class="term">ALL</span></dt> <dd> <p>Search all messages.</p> </dd> <dt><span class="term"><em class="replaceable"><code>range</code></em></span></dt> <dd> <p><em class="replaceable"><code>range</code></em> is a comma-separated range of message numbers to search. Consecutive message numbers may be given as <em class="replaceable"><code>A</code></em>-<em class="replaceable"><code>B</code></em>, indicating messages A through B, inclusive.</p> </dd> </dl> </div> <p>Each <code class="literal">SEARCH</code> command specifies a single search criteria. Simple criterias are combined to form more complicated searches by using a series of <code class="literal">SEARCH</code> and <code class="literal">STORE</code> commands. First, all messages have their <code class="literal">MARKED</code> flag cleared. The list of messages found by the first <code class="literal">SEARCH MARKED</code> command is fed into the <code class="literal">STORE</code> command, setting their marked flags. Then additional searches are performed, using <code class="literal">SEARCH MARKED</code> or <code class="literal">SEARCH UNMARKED</code>, with or without the <code class="literal">NOT</code> keyword, forming a complex query.</p> <p>The <code class="literal">NOT</code> keyword optional follows, and indicates that the following search criteria specification should be logically inverted. For example, if the search is for messages with the subject line containing “<span class="quote">foo</span>”, the search will not be for messages whose subject line does not contain “<span class="quote">foo</span>”.</p> <p>The available search criteria are:</p> <div class="variablelist"> <dl> <dt><span class="term">REPLIED</span></dt> <dd> <p>Search for messages that have the <code class="literal">REPLIED</code> flag set.</p> </dd> <dt><span class="term">DELETED</span></dt> <dd> <p>Search for messages that have the <code class="literal">DELETED</code> flag set.</p> </dd> <dt><span class="term">DRAFT</span></dt> <dd> <p>Search for messages that have the <code class="literal">DRAFT</code> flag set.</p> </dd> <dt><span class="term">SEEN</span></dt> <dd> <p>Search for messages that have the <code class="literal">SEEN</code> flag set.</p> </dd> <dt><span class="term">FROM <em class="replaceable"><code>string</code></em></span></dt> <dd> <p>Search for messages that have <em class="replaceable"><code>string</code></em> in their “<span class="quote"><code class="literal">From:</code></span>” header.</p> </dd> <dt><span class="term">TO <em class="replaceable"><code>string</code></em></span></dt> <dd> <p>Search for messages that have <em class="replaceable"><code>string</code></em> in their “<span class="quote"><code class="literal">To:</code></span>” header.</p> </dd> <dt><span class="term">CC <em class="replaceable"><code>string</code></em></span></dt> <dd> <p>Search for messages that have <em class="replaceable"><code>string</code></em> in their “<span class="quote"><code class="literal">Cc:</code></span>” header.</p> </dd> <dt><span class="term">BCC <em class="replaceable"><code>string</code></em></span></dt> <dd> <p>Search for messages that have <em class="replaceable"><code>string</code></em> in their “<span class="quote"><code class="literal">Bcc:</code></span>” header.</p> </dd> <dt><span class="term">SUBJECT <em class="replaceable"><code>string</code></em></span></dt> <dd> <p>Search for messages that have <em class="replaceable"><code>string</code></em> in their “<span class="quote"><code class="literal">Subject:</code></span>” header.</p> </dd> <dt><span class="term">HEADER <em class="replaceable"><code>header</code></em> <em class="replaceable"><code>string</code></em></span></dt> <dd> <p>Search for messages that have <em class="replaceable"><code>string</code></em> in their “<span class="quote"><em class="replaceable"><code>header</code></em></span>” (without the colon) header.</p> </dd> <dt><span class="term">BODY <em class="replaceable"><code>string</code></em></span></dt> <dd> <p>Search for messages that have <em class="replaceable"><code>string</code></em> in their content.</p> </dd> <dt><span class="term">TEXT <em class="replaceable"><code>string</code></em></span></dt> <dd> <p>Search for messages that have <em class="replaceable"><code>string</code></em> in their content or headers.</p> </dd> <dt><span class="term">BEFORE <em class="replaceable"><code>mm-ddd-yyyy</code></em></span></dt> <dd> <p>Search for messages whose <code class="literal">INTERNALDATE</code> is earlier than <em class="replaceable"><code>mm-ddd-yyyy</code></em>.</p> </dd> <dt><span class="term">ON <em class="replaceable"><code>mm-ddd-yyyy</code></em></span></dt> <dd> <p>Search for messages whose <code class="literal">INTERNALDATE</code> is <em class="replaceable"><code>mm-ddd-yyyy</code></em>.</p> </dd> <dt><span class="term">SINCE <em class="replaceable"><code>mm-ddd-yyyy</code></em></span></dt> <dd> <p>Search for messages whose <code class="literal">INTERNALDATE</code> is on or after <em class="replaceable"><code>mm-ddd-yyyy</code></em>.</p> </dd> <dt><span class="term">SENTBEFORE <em class="replaceable"><code>mm-ddd-yyyy</code></em></span></dt> <dd> <p>Search for messages whose <code class="literal">Date:</code> header is prior to <em class="replaceable"><code>mm-ddd-yyyy</code></em>.</p> </dd> <dt><span class="term">SENTON <em class="replaceable"><code>mm-ddd-yyyy</code></em></span></dt> <dd> <p>Search for messages whose <code class="literal">Date:</code> header reads <em class="replaceable"><code>mm-ddd-yyyy</code></em>.</p> </dd> <dt><span class="term">SENTSINCE <em class="replaceable"><code>mm-ddd-yyyy</code></em></span></dt> <dd> <p>Search for messages whose <code class="literal">Date:</code> header reads on or after <em class="replaceable"><code>mm-ddd-yyyy</code></em>.</p> </dd> <dt><span class="term">LARGER <em class="replaceable"><code>n</code></em></span></dt> <dd> <p>Search for messages whose estimated size is more than <em class="replaceable"><code>n</code></em> bytes.</p> </dd> <dt><span class="term">SMALLER <em class="replaceable"><code>n</code></em></span></dt> <dd> <p>Search for messages whose estimated size is less than <em class="replaceable"><code>n</code></em> bytes.</p> </dd> </dl> </div> <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> <h3 class="title">Note</h3> <p>All text strings above use the UTF-8 character set. For header or content searches, the search string must be converted to the header's (MIME-encoded) or content's character set. Searching should be case insensitive.</p> <p>Date-based searches specify months by their short English names.</p> </div> <p>The server's <code class="literal">* SEARCH</code> reply enumerates messages found by the search. For extremely large folders, the server may send multiple <code class="literal">* SEARCH</code> replies in order to keep line lengths under the maximum. No <code class="literal">* SEARCH</code> replies are sent when no messages are found by the search criteria.</p> </div> <div class="navfooter"> <hr/> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left" rowspan="1" colspan="1"> <a accesskey="p" href="smapcopymovemessages.html" shape="rect">Prev</a> </td> <td width="20%" align="center" rowspan="1" colspan="1"> <a accesskey="u" href="smap1.html" shape="rect">Up</a></td> <td width="40%" align="right" rowspan="1" colspan="1">  <a accesskey="n" href="smaplogout.html" shape="rect">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top" rowspan="1" colspan="1">Copying and moving messages </td> <td width="20%" align="center" rowspan="1" colspan="1"> <a accesskey="h" href="index.html" shape="rect">Home</a> | <a accesskey="t" href="bk01-toc.html" shape="rect">ToC</a></td> <td width="40%" align="right" valign="top" rowspan="1" colspan="1"> Logging off</td> </tr> </table> </div> </body> </html>