Struct mailparse::ParsedMail
[−]
[src]
pub struct ParsedMail<'a> { pub headers: Vec<MailHeader<'a>>, pub ctype: ParsedContentType, pub subparts: Vec<ParsedMail<'a>>, // some fields omitted }
Struct that holds the structured representation of the message. Note that since MIME allows for nested multipart messages, a tree-like structure is necessary to represent it properly. This struct accomplishes that by holding a vector of other ParsedMail structures for the subparts.
Fields
headers: Vec<MailHeader<'a>>
The headers for the message (or message subpart).
ctype: ParsedContentType
The Content-Type information for the message (or message subpart).
subparts: Vec<ParsedMail<'a>>
The subparts of this message or subpart. This vector is only non-empty if ctype.mimetype starts with "multipart/".
Methods
impl<'a> ParsedMail<'a>
[src]
fn get_body(&self) -> Result<String, MailParseError>
Get the body of the message as a Rust string. This function tries to unapply the Content-Transfer-Encoding if there is one, and then converts the result into a Rust UTF-8 string using the charset in the Content-Type (or "us-ascii" if the charset was missing or not recognized).
Examples
use mailparse::parse_mail; let p = parse_mail(concat!( "Subject: test\n", "\n", "This is the body").as_bytes()) .unwrap(); assert_eq!(p.get_body().unwrap(), "This is the body");