简体   繁体   中英

Node.js: How can I just access the “To”, “Body” and “From” fields of an e-mail received using node-imap?

I'm using node-imap to get my Gmail e-mails and although their example runs pretty well, I'm not being able to only print the msg.To , msg.Body , and msg.From . I can only print the entire message, which is a lot.

Thanks.

According to the documentation for node-imap, the To and From headers are available in the msg.headers , which includes the To and From. In order to retrieve the body you must append a variable every time the chunk event is emitted, and upon end you should have a completed body. The headers will probably also not be fully available until the end event has been triggered, so you must take that into account.

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