Permalink
Browse files

Added example on how to fetch additional header fields.

1 parent 9a3d688 commit 3cfcdca2ffaf2a7d6707effe21876f6d176f3710 @vincent-richard vincent-richard committed Feb 10, 2017
Showing with 7 additions and 11 deletions.
  1. +7 −11 examples/example6.cpp
View
@@ -542,22 +542,18 @@ static void connectStore()
// Show message envelope
case 4:
+ {
+ vmime::net::fetchAttributes attr(vmime::net::fetchAttributes::ENVELOPE);
- f->fetchMessage(msg, vmime::net::fetchAttributes::ENVELOPE);
-
-#define ENV_HELPER(x) \
- try { std::cout << msg->getHeader()->x()->generate() << std::endl; } \
- catch (vmime::exception) { /* In case the header field does not exist. */ }
+ // If you also want to fetch "Received: " fields:
+ //attr.add("Received");
- ENV_HELPER(From)
- ENV_HELPER(To)
- ENV_HELPER(Date)
- ENV_HELPER(Subject)
+ f->fetchMessage(msg, attr);
-#undef ENV_HELPER
+ std::cout << msg->getHeader()->generate() << std::endl;
break;
-
+ }
// Extract whole message
case 5:
{

0 comments on commit 3cfcdca

Please sign in to comment.