~asimpson/mailpreview-cli

33a6db285aad47fec3ad0e6f402bca3de945154c — Adam Simpson 2 years ago 51caa63 v0.1.2
fix: account for multipart/alternative
3 files changed, 9 insertions(+), 2 deletions(-)

M Cargo.lock
M Cargo.toml
M src/main.rs
M Cargo.lock => Cargo.lock +1 -1
@@ 59,7 59,7 @@ dependencies = [

[[package]]
name = "mailpreview-cli"
version = "0.1.0"
version = "0.1.2"
dependencies = [
 "mailparse",
]

M Cargo.toml => Cargo.toml +1 -1
@@ 1,6 1,6 @@
[package]
name = "mailpreview-cli"
version = "0.1.1"
version = "0.1.2"
authors = ["Adam Simpson <adam@adamsimpson.net"]
edition = "2018"


M src/main.rs => src/main.rs +7 -0
@@ 9,6 9,13 @@ fn return_body(mail: ParsedMail, format: String) -> Result<String, MailParseErro

    if mail.subparts.len() > 0 {
        for m in mail.subparts.iter() {
            if m.ctype.mimetype == "multipart/alternative" {
              for i in m.subparts.iter() {
                if i.ctype.mimetype == format {
                  body = i.get_body()?;
                }
              }
            }
            if m.ctype.mimetype == format {
                body = m.get_body()?;
            }