1MAIL::MIMESTRUCT(3x) Extra/Miscellaneous objects/methods MAIL::MIMESTRUCT(3x)
2
3
4
6 mail::mimestruct - Message MIME structure
7
9 #include <libmail/structure.H>
10
11 mail::mimestruct myMimeStructure;
12
14 mail::mimestruct describes the contents of a MIME-formatted message. A
15 multipart MIME message has a single mail::mimestruct object that repre‐
16 sents the entire message, and series of mail::mimestruct objects, one
17 object for each part of the multipart MIME section. The additional
18 mail::mimestruct objects are maintained by their parent
19 mail::mimestruct object, and are automatically destroyed when the par‐
20 ent object is destroyed.
21
22 A mail::mimestruct contains the following fields:
23
24 std::string mime_id
25 An opaque identifier of this MIME section. Applications should
26 handle this field as an opaque text string, which is interpreted
27 by LibMAIL . A same message, for example, may have different
28 mime_id fields if it comes from an IMAP account, or a POP3
29 account.
30
31 The only exception to this rule is that the mail::mimestruct
32 object that represents the entire message will have an empty
33 string in mime_id.
34
35 std::string type
36 The major MIME type, in uppercase.
37
38 std::string subtype
39 The minor MIME subtype, in uppercase.
40
41 mail::mimestruct::parameterList type_parameters
42 Additional attributes parsed from the Content-Type: MIME header.
43 See below for more information.
44
45 std::string content_id
46 The contents of the MIME Content-ID: header.
47
48 std::string content_description
49 The contents of the MIME Content-Description: header.
50
51 std::string content_transfer_encoding
52 The MIME encoding method.
53
54 std::string content_md5
55 The contents of the MIME Content-MD5: header.
56
57 std::string content_language
58 The contents of the MIME Content-Language: header.
59
60 std::string content_disposition
61 The MIME Content-Disposition: header, either "INLINE", or
62 "ATTACHMENT" (or blank, if the header is not present).
63
64 size_t content_size
65 The approximate size of the MIME section, in bytes (for non-mul‐
66 tipart MIME sections only).
67
68 size_t content_lines
69 Approximate number of lines in a TEXT MIME section.
70
71 mail::mimestruct::parameterList content_disposition_parameters
72 Additional attributes parsed from the Content-Disposition: MIME
73 header. See below for more information.
74
75 MAIL::MIMESTRUCT METHODS
76 bool flag=messagerfc822();
77 Returns true if type is "MESSAGE" and subtype is "RFC822".
78
79 bool flag=messagerfc822()
80 Returns true if type is "MESSAGE" and subtype is "RFC822".
81
82 mail::envelope &myEnvelope=getEnvelope()
83 Returns a mail::envelope object, if messagerfc822 returns true.
84
85 size_t numChildren=getNumChildren()
86 Returns the number of MIME sections in a multipart MIME message.
87
88 mail::mimestruct *child=getChild(size_t childNum)
89 Returns a pointer to a mail::mimestruct object that represents a
90 single part of a multipart MIME message. childNum must be
91 between zero and one less than the number of parts returned by
92 getNumChildren.
93
94 mail::mimestruct *parent=getParent()
95 Returns a pointer to a mail::mimestruct object that represents
96 the parent of this MIME part, if this mail::mimestruct object
97 represents a single part of a multipart MIME message. Returns
98 NULL if this mail::mimestruct object represents the entire MIME
99 message.
100
101 Note: mail::mimestruct objects that represent MESSAGE/RFC822
102 content should have getNumChildren return 1, and getChild with
103 childNum set to 0 should return a pointer to a mail::mimestruct
104 object that represents the MESSAGE/RFC822 message. However,
105 getNumChildren may return 0 if the MIME message is corrupted.
106
108 A mail::mimestruct::parameterList object holds parsed MIME attributes
109 in the Content-Type: and Content-Disposition: headers. A
110 mail::mimestruct::parameterList object has the following methods:
111
112 bool flag=exists(std::string name);
113 This method returns true if the attribute name exists.
114
115 std::string str=get(std::string name, const struct unicode_info
116 *info=NULL);
117 Returns the value of attribute name (uppercase). If info is not
118 NULL, the attribute's value is converted to the specified char‐
119 acter set (if the attribute uses RFC 2231 to specify its charac‐
120 ter set and language).
121
122 void set(std::string name, std::string value, std::string charset,
123 std::string language);
124 Set the attribute name to value. If charset and/or language are
125 not empty strings, name's character set and language are indi‐
126 cated accordingly, as per RFC 2231.
127
128 mail::mimestruct::parameterList::iterator begin(), end();
129 mail::mimestruct::parameterList::const_iterator begin() const, end()
130 const;
131 The begin and end functions return the equivalent iterators over
132 the individual name/value MIME attributes. The iterators point
133 to a std::pair<std::string, std::string>; first is the attribute
134 name (uppercased), and second is its value. (The underlying
135 structure being iterated is a std::map<std::string,
136 std::string>.)
137
139 mail::envelope(3x), mail::account::readMessageAttributes(3x).
140
141
142
143 10 April 2006 MAIL::MIMESTRUCT(3x)