Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Internet Protocols Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

9.7 Program: Processing a Simple MIME Message

Example 29 uses the MIME package to process a simple MIME message and print the components of the message to standard output. The message processed is essentially identical to the message generated in Example 27. We've taken shortcuts to keep the example simple. A production application would normally check to make sure that the message received is actually a simple MIME message before processing the message (see Section 9.6.5). Source for this program is in BasicMimeMessageDecomposition.cpp in the examples\mime directory.


NOTE -- Sample programs are located in the examples directory created for your installation. For more information, see Installing and Building Your SourcePro C++ Products and Building Your Applications.

Example 29: Processing a simple MIME message

//1Defines the message as a constant string to keep the example short. A production application would obtain the message from outside the program.
//2Creates an empty RWMimePart.
//3Populates the part with the contents of messageStr. In a production application, the call to fromString() would be enclosed in a try block. We've left out the try block since the example uses a constant string.
//4The for loop on this line increments pos to index each header in the message. To find a specific header, you could also use the findHeader() function of RWMimePart.
//5Retrieves the header at position pos.
//6Prints the header label and the header value to standard output.
//7Prints the message body to standard output. This command prints the message body exactly as the body appears in the MIME message. A production application would typically decode the body and convert the body from canonical text before displaying the body or processing the body further.

This program generates the following output:



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.