aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-12-31 16:00:16 +0000
committerSteve Holme <steve_holme@hotmail.com>2013-12-31 16:13:22 +0000
commitab71241c88693ed25e24e74ab41fde1117229a66 (patch)
tree029e15050e8f0e0f9b08fe145beec752e909b454
parente9625c5bc6c046a7fbd90149ee48ecfd7e1c8564 (diff)
examples: Updated IMAP fetch example for libcurl 7.30.0
-rw-r--r--docs/examples/imap-fetch.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/docs/examples/imap-fetch.c b/docs/examples/imap-fetch.c
index ba07f022a..aa1f833e0 100644
--- a/docs/examples/imap-fetch.c
+++ b/docs/examples/imap-fetch.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,6 +22,12 @@
#include <stdio.h>
#include <curl/curl.h>
+/* This is a simple example showing how to fetch mail using libcurl's IMAP
+ * capabilities.
+ *
+ * Note that this example requires libcurl 7.30.0 or above.
+ */
+
int main(void)
{
CURL *curl;
@@ -32,13 +38,20 @@ int main(void)
/* Set username and password */
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
- /* This will fetch the mailbox named "foobar" */
- curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/foobar");
+ /* This will fetch message 1 from the user's inbox */
+ curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1");
+ /* Perform the fetch */
res = curl_easy_perform(curl);
- /* always cleanup */
+ /* Check for errors */
+ if(res != CURLE_OK)
+ fprintf(stderr, "curl_easy_perform() failed: %s\n",
+ curl_easy_strerror(res));
+
+ /* Always cleanup */
curl_easy_cleanup(curl);
}
+
return (int)res;
}