gmail-fetcher
v1.0.0
Published
Fetch mails from your inbox easily.
Downloads
2
Readme
GmailFetch
GmailFetch is a Node.js package that allows you to fetch and process emails from a Gmail account using the Gmail API. The package provides a simple interface to retrieve email messages, clean them, and extract relevant information such as the sender, subject, and text content. You just need to add your OAUTH credentials, tokens and number of mails to fetch and your task is done !!
Installation
To install the package, use npm:
npm install gmail-fetch
Example Code
Here’s how to use the gmail-fetch
package:
const GmailFetch = require("gmail-fetch");
const fetchEmails = async () => {
const { gmailFetch } = new GmailFetch({
accessToken: "your-access-token",
refreshToken: "your-refresh-token",
clientId: "your-client-id",
clientSecret: "your-client-secret",
mailsToFetch: 5,
});
const emails = await gmailFetch.fetchEmails();
console.log(emails);
};
fetchEmails();
Returned Data
[
{
id: "unique-message-id",
senderEmail: "[email protected]",
subject: "Email Subject",
snippet: "A short snippet of the email...",
textContent: "The full text content of the email...",
},
// more emails...
];