<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: codefromrvk</title>
    <description>The latest articles on DEV Community by codefromrvk (@codefromrvk).</description>
    <link>https://dev.to/codefromrvk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F665815%2F4e7eb4c5-0b19-492d-a6d3-5acf76ad5609.png</url>
      <title>DEV Community: codefromrvk</title>
      <link>https://dev.to/codefromrvk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codefromrvk"/>
    <language>en</language>
    <item>
      <title>Gmail API with expo react native</title>
      <dc:creator>codefromrvk</dc:creator>
      <pubDate>Wed, 12 Jul 2023 13:42:17 +0000</pubDate>
      <link>https://dev.to/codefromrvk/gmail-api-with-expo-react-native-1d2n</link>
      <guid>https://dev.to/codefromrvk/gmail-api-with-expo-react-native-1d2n</guid>
      <description>&lt;p&gt;Lets start by creating a react native project using expo &lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-expo-app my-app &amp;amp;&amp;amp; cd my-app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run the app using &lt;code&gt;npx expo start&lt;/code&gt;. Ensure your react native app is up and running!&lt;/p&gt;

&lt;p&gt;Now let's create a google console project to get the google API access.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open &lt;a href="https://console.google.com" rel="noopener noreferrer"&gt;Google console&lt;/a&gt;. On the top left click on the rectangular button . It should mostly say My First project if you havent worked in GCP before else click if you are too lazy &lt;a href="https://console.cloud.google.com/projectcreate" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fshs2ax0ccsi503on2u6h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fshs2ax0ccsi503on2u6h.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Click on new project&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyark7dd6tpxuc694tunt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyark7dd6tpxuc694tunt.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Give a name&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffz8zpqt5f7uhdadoiog6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffz8zpqt5f7uhdadoiog6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on create . &lt;br&gt;
After creating the project, now when you click on the top left button, the newly created project should be visible (google-permission) . Select the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fws60mzpjlev5s3fkg49y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fws60mzpjlev5s3fkg49y.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on the navigation menu &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4zzade5ut4pto9wm528o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4zzade5ut4pto9wm528o.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select APIs &amp;amp; Services &amp;gt; oAuth Consent screen&lt;/p&gt;

&lt;p&gt;Choose the desired User type . &lt;br&gt;
I will be choosing External and proceeding further .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F71ecuyjfrx69levqhgcy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F71ecuyjfrx69levqhgcy.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fill in the consent form with app name, user supported email and developer information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvvbb1ujpyxybzsngomor.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvvbb1ujpyxybzsngomor.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzx4yvzt02j6q9kb5tpfu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzx4yvzt02j6q9kb5tpfu.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click save &amp;amp; continue .&lt;/p&gt;

&lt;p&gt;SKIP this if your life is good till here:&lt;br&gt;
Sometimes you might get an error saying &lt;code&gt;something went wrong&lt;/code&gt;. This is mostly because of the app name. Instead of you asking chatGPT and going through stack-overflow . I have a solution. &lt;br&gt;
The solution is to change your app name to your project ID.&lt;/p&gt;

&lt;p&gt;Where do you find the project ID? &lt;br&gt;
On the top left , click on the rectangular button with your project name and you should find the project ID here&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hm8ivixrc1ubjxrehaq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hm8ivixrc1ubjxrehaq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My project ID was &lt;code&gt;orbital-nova-392310&lt;/code&gt; and I pasted that and submitted. Now you should be able to navigate to step of the form.&lt;br&gt;
In the scope section, click on Add or remove scopes . Select some basic info APIs - openID,profile,email.&lt;br&gt;
Scroll down, there will be a section called manually add scope.&lt;br&gt;
Here you can add any scope of your choice but for this article we will stick to gmail send API.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp29gs0ui4kesoaqkxo8i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp29gs0ui4kesoaqkxo8i.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80fe0nqnfjnuq2mvp4a9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80fe0nqnfjnuq2mvp4a9.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Paste the scope URL, click on add to table and then update. &lt;/p&gt;

&lt;p&gt;To see all the list of the scope you can refer: &lt;a href="https://developers.google.com/identity/protocols/oauth2/scopes" rel="noopener noreferrer"&gt;Scope list page&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpaizhty2rhh3c33b5zp4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpaizhty2rhh3c33b5zp4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now under your sensitive scopes section you should see the gmail send scope added. Click on Save and continue.&lt;/p&gt;

&lt;p&gt;Add test users in your application and then again click save and continue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftdj305aorl9up4ubewt1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftdj305aorl9up4ubewt1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the summary section, scroll down and click on the back to dashboard button.&lt;/p&gt;

&lt;p&gt;With this oAuth consent screen info is filled successfully.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now let us create credentials required for our app.
Click on the credentials option in the navigation menu.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpronizkgzcrpgrx85zm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpronizkgzcrpgrx85zm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on create credential,thens elect oAuth Client ID.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0uvjrslt2vpjtahv469h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0uvjrslt2vpjtahv469h.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the application type as web application .( Do not select android, in this article ,the google API permissions will be requested from a browser)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkxqjm06mis79uehrybud.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkxqjm06mis79uehrybud.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give the authorized redirect URL . This url is basically your web server url . I have added a &lt;a href="https://ngrok.com/download" rel="noopener noreferrer"&gt;ngrok&lt;/a&gt; url and localhost url . Click on Create.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqbs2nw9fk4qd3l57zm7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqbs2nw9fk4qd3l57zm7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now a modal pops up. Download your credential json file .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7rn2y33oo2jdfp3zl8do.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7rn2y33oo2jdfp3zl8do.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is one more thing left to start building. That is to Enable GAMIL API.&lt;/p&gt;

&lt;p&gt;Click on Enabled APIs and services in the navigation menu. Search and enable the GMAIL API.&lt;/p&gt;

&lt;p&gt;YAY!! Your gmail API setup is done.&lt;/p&gt;

&lt;p&gt;We can now use this in our react native application .&lt;/p&gt;

&lt;p&gt;Reat native frontend code - &lt;a href="https://github.com/codefromrvk/gmail-api-react-native" rel="noopener noreferrer"&gt;https://github.com/codefromrvk/gmail-api-react-native&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;There are two buttons, verify identity and send email. &lt;/p&gt;

&lt;p&gt;Verify identity button, opens the browser and requests permission to the google account .&lt;/p&gt;

&lt;p&gt;Send email button , sends email from the authorized email.&lt;/p&gt;

&lt;p&gt;There are two REST endpoints used in the above frontend code:&lt;br&gt;
&lt;code&gt;/gmail/link&lt;/code&gt;, &lt;code&gt;/gmail/send-proposal&lt;/code&gt;.&lt;br&gt;
I have used express as my backend framework to built them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// router.js
router.get("/gmail/link", getGmailLink);
router.get("/gmail/send-proposal", sendProposal);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// controller.js

const getGmailLink = async (req, res) =&amp;gt; {

  try {

    // When generating the url if you want the userId( or any other key) to be also present as a param for your frontend to identify, you can concat it with the generated url.

    const genURL = generateURL();

    // + `&amp;amp;state=${userID}`;


    res.status(HttpStatus.StatusCodes.OK).send({
      status: "Email sent successfully",
      data: genURL,
    });
  } catch (error) {
    console.log(error);
  }
};


const sendProposal = async (req, res) =&amp;gt; {

  try {
    const emailQR = await gmailSVC.sendGmailProposal();
    res.status(HttpStatus.StatusCodes.OK).send({
      status: "Proposal sent ",
      data: emailQR,
    });
  } catch (error) {
    res.status(HttpStatus.StatusCodes.INTERNAL_SERVER_ERROR).send({
      status: "Failed to send proposal ",
    });

  }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: config.json is the json file you downloaded from your GCP project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// service.js

const credentials = require("config.json");
const { google } = require("googleapis");
const GMAIL_SCOPES = ["https://www.googleapis.com/auth/gmail.send"];

function generateURL() {
  try {
    const { client_secret, client_id, redirect_uris } = credentials.web;
    const oAuth2Client = new google.auth.OAuth2(
      client_id,
      client_secret,
      redirect_uris
    );

    const url = oAuth2Client.generateAuthUrl({
      access_type: "offline",
      prompt: "consent",
      scope: GMAIL_SCOPES,
    });
    return url;
  } catch (error) {
    throw error;
  }
}


const sendGmailProposal = async () =&amp;gt; {
  return new Promise(async (resolve, reject) =&amp;gt; {
    try {
        const fileContent = fs.readFileSync("credentials.txt", "utf-8");
        const [accessToken, refreshToken] = fileContent
          .split("\n")[1]
          .split(",");

        console.log("Access Token:", accessToken);
        console.log("Refresh Token:", refreshToken);

        const messageId = await sendMail(refreshToken);
        resolve(messageId);
    } catch (error) {
      reject(error);
    }
  });
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// util.js
const { google } = require("googleapis");
const MailComposer = require("nodemailer/lib/mail-composer");
const credentials = require("config.json");

const createMail = async (options) =&amp;gt; {
  const mailComposer = new MailComposer(options);
  const message = await mailComposer.compile().build();
  return encodeMessage(message);
};

const sendMail = async (refresh_token) =&amp;gt; {
  const gmail = await getGmailService(refresh_token);
  const fileAttachments = [
    {
      filename: "TestAttachment.jpg",
      path: "[imageURL]",
    },
  ];

  const options = {
    to: `varshithkumar553@gmail.com`,
    subject: "Sales Proposal",
    text: "This email is sent from the command line",
    html: `&amp;lt;body&amp;gt;
    &amp;lt;h4&amp;gt;Hello world&amp;lt;/h4&amp;gt;



  &amp;lt;/body&amp;gt;`,
    // attachments: fileAttachments,
    textEncoding: "base64",
    headers: [
      { key: "X-Application-Developer", value: "VARSHITH" },
      { key: "X-Application-Version", value: "v1.0.0.2" },
    ],
  };
  console.log("Before rawMessa");

  const rawMessage = await createMail(options);
  // console.log("after rawMessa",rawMessage);
  try {
    const {
      data: { id },
    } = await gmail.users.messages.send({
      userId: "me",
      resource: {
        raw: rawMessage,
      },
    });
    console.log("id generated", rawMessage);
    return id;
  } catch (error) {
    console.log({ error });
  }
};


const encodeMessage = (message) =&amp;gt; {
  return Buffer.from(message)
    .toString("base64")
    .replace(/\+/g, "-")
    .replace(/\//g, "_")
    .replace(/=+$/, "");
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thats it! Now you can send any number of emails from your gmail account.&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me @ &lt;a href="mailto:varshithkumar553@gmail.com"&gt;varshithkumar553@gmail.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/0xrvk" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; &lt;br&gt;
&lt;a href="https://github.com/codefromrvk" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>gmail</category>
      <category>gcp</category>
    </item>
  </channel>
</rss>
