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 30 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 28. 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.


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 30: Processing a simple MIME message

//1

Defines the message as a constant string to keep the example short. A production application would obtain the message from outside the program.

//2

Creates an empty RWMimePart.

//3

Populates 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.

//4

The 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.

//5

Retrieves the header at position pos.

//6

Prints the header label and the header value to standard output.

//7

Prints 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 DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.