简体   繁体   中英

How can I read an email's body text with Chilkat and Node.js?

So, I currently have a node.js project that uses chilkat in order to read emails. Currently it does most of what I'm looking for, returning the subject, header, and the email address of each email. The only thing I can't get to return is the body text. Currently when I try to do so, it returns either an empty of null result.

I know why the problem happens. It's because I am only fetching email header info here before trying to print the result:

var bundle;
bundle = imap.FetchHeaders(messageSet);
if (imap.LastMethodSuccess == false) {

    console.log(imap.LastErrorText);
    return;
}

var i = 0;
while (i < bundle.MessageCount) {
    // email: Email
    var email;
    email = bundle.GetEmail(i);

    console.log(email.GetHeaderField("Date"));
    console.log(email.Subject);
    console.log(email.From);
    console.log(email.Body);
    console.log("--");

    i = i+1;
}

So, I know the fix should happen here, but for the life of me I can't find what should go in place the the imap.FetchHeaders() part.

使用FetchBundle()代替FetchHeaders()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM