ballerinax/googleapis.gmail

3.2.0

Overview

Ballerina Gmail Connector provides the capability to send, read, and delete emails through the Gmail REST API. It also provides the ability to read, trash, untrash, and delete threads, as well as the ability to get the Gmail profile and mailbox history, etc. The connector supports OAuth 2.0 authentication.

This module supports Gmail API v1.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

  1. Create a Google account. (If you already have one, you can use that.)

  2. Obtain tokens

Quickstart

To use the Gmail connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

Import the ballerinax/googleapis.gmail module into the Ballerina project.

Copy

Step 2: Create a new connector instance

Create a gmail:ConnectionConfig with the OAuth 2.0 tokens obtained, and initialize the connector with it.

Copy

Step 3: Invoke connector operation

  1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.
    Following is an example on how to send an email using the connector.

    Copy
  2. Use bal run command to compile and run the Ballerina program.

You can find a list of samples here

Other versions

See more...