donald
donald

Reputation: 23767

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.

Upvotes: 3

Views: 1239

Answers (1)

Bryan
Bryan

Reputation: 717

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.

Upvotes: 3

Related Questions