From 5915ca4e34d2192cb3ef06c8f47aaa4b16cf7f53 Mon Sep 17 00:00:00 2001
From: Vincent Richard <vincent@vincent-richard.net>
Date: Thu, 14 Nov 2013 23:17:40 +0100
Subject: Custom fetch attributes.

---
 doc/book/net.tex | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

(limited to 'doc/book/net.tex')

diff --git a/doc/book/net.tex b/doc/book/net.tex
index 8b1c7fa7..88249c1c 100644
--- a/doc/book/net.tex
+++ b/doc/book/net.tex
@@ -560,8 +560,8 @@ std::vector <ref <vmime::net::message> > allMessages =
       // -1 is a special value to mean "the number of the last message in the folder"
 
 folder->fetchMessages(allMessages,
-   vmime::net::folder::FETCH_FLAGS |
-   vmime::net::folder::FETCH_ENVELOPE);
+   vmime::net::fetchAttributes::FLAGS |
+   vmime::net::fetchAttributes::ENVELOPE);
 
 for (unsigned int i = 0 ; i < allMessages.size() ; ++i)
 {
@@ -583,6 +583,21 @@ for (unsigned int i = 0 ; i < allMessages.size() ; ++i)
 }
 \end{lstlisting}
 
+IMAP supports fetching specific header fields of a message. Here is how to use
+the {\vcode fetchAttributes} object to do it:
+
+\begin{lstlisting}[caption={Using fetchAttributes object to fetch specific header fields of a message}]
+
+// Fetch message flags and the "Received" and "X-Mailer" header fields
+vmime::net::fetchAttributes fetchAttribs;
+fetchAttribs.add(vmime::net::fetchAttributes::FLAGS);
+fetchAttribs.add("Received");
+fetchAttribs.add("X-Mailer");
+
+folder->fetchMessages(allMessages, fetchAttribs);
+\end{lstlisting}
+
+
 \subsection{Extracting messages and parts}
 
 To extract the whole contents of a message (including headers), use the
@@ -605,7 +620,7 @@ and time. The method {\vcode extractPart()} is used in this case:
 
 \begin{lstlisting}[caption={Extracting a specific MIME part of a message}]
 // Fetching structure is required before extracting a part
-folder->fetchMessage(msg, vmime::net::folder::FETCH_STRUCTURE);
+folder->fetchMessage(msg, vmime::net::fetchAttributes::STRUCTURE);
 
 // Now, we can extract the part
 msg->extractPart(msg->getStructure()->getPartAt(0)->getPartAt(1));
-- 
cgit v1.2.3

