aboutsummaryrefslogtreecommitdiffstats
path: root/examples/example6.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2017-02-10 20:53:33 +0000
committerVincent Richard <[email protected]>2017-02-10 20:53:33 +0000
commit3cfcdca2ffaf2a7d6707effe21876f6d176f3710 (patch)
tree41226a5c41e2318401a2af424e6363bd6606d88f /examples/example6.cpp
parentFixed issue #160: invalid characters in hostname. (diff)
downloadvmime-3cfcdca2ffaf2a7d6707effe21876f6d176f3710.tar.gz
vmime-3cfcdca2ffaf2a7d6707effe21876f6d176f3710.zip
Added example on how to fetch additional header fields.
Diffstat (limited to 'examples/example6.cpp')
-rw-r--r--examples/example6.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/examples/example6.cpp b/examples/example6.cpp
index c2f0c2dd..91a5ba5d 100644
--- a/examples/example6.cpp
+++ b/examples/example6.cpp
@@ -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:
{