~aodag/maildirview

ref: f4296562fa77a04cc93aae837774ec78b6bf1387 maildirview/viewer/src/main.rs -rw-r--r-- 568 bytes
f4296562Atsushi Odagiri add license 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use maildir::*;
use mailparse::*;
use std::env::args;

fn get_subject(headers: Vec<MailHeader>) -> Result<String, ()> {
    for h in headers {
        if h.get_key() == "Subject" {
            return Ok(h.get_value());
        }
    }
    Err(())
}

fn main() {
    for dir in args() {
        let maildir = Maildir::from(dir);
        for entry in maildir.list_new() {
            match get_subject(entry.unwrap().headers().unwrap()) {
                Ok(s) => println!("Subject: {}", s),
                Err(_) => println!("failed"),
            }
        }
    }
}