node-gmail-fetcher

1.0.0 • Public • Published

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 node-gmail-fetcher

Example Code

Here’s how to use the node-gmail-fetcher package:

const { GmailFetch } = require("node-gmail-fetcher");

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: "sender@example.com",
    subject: "Email Subject",
    snippet: "A short snippet of the email...",
    textContent: "The full text content of the email...",
  },
  // more emails...
];

Readme

Keywords

none

Package Sidebar

Install

npm i node-gmail-fetcher

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

5.99 kB

Total Files

4

Last publish

Collaborators

  • raj18