Compartir a través de


Gmail

Gmail is a web-based email service from Google. With the Gmail connector, you can perform actions such as send or receive e-mail messages, and trigger flows on new e-mails.

This connector is available in the following products and regions:

Service Class Regions
Logic Apps Standard All Logic Apps regions except the following:
     -   Azure China regions
     -   US Department of Defense (DoD)
Power Automate Standard All Power Automate regions except the following:
     -   US Government (GCC High)
     -   China Cloud operated by 21Vianet
     -   US Department of Defense (DoD)
Power Apps Standard All Power Apps regions except the following:
     -   US Government (GCC High)
     -   China Cloud operated by 21Vianet
     -   US Department of Defense (DoD)
Contact
Name Microsoft
URL Microsoft LogicApps Support
Microsoft Power Automate Support
Microsoft Power Apps Support
Connector Metadata
Publisher Microsoft
Website https://mail.google.com/mail/
Privacy policy https://policies.google.com/privacy

Authentication and Bring your own application

The Gmail connector now supports multiple authentication types:

  • Use default shared application
  • Bring your own application

The default shared application uses a Google Client application maintained by Microsoft. In this case, when you sign into your Gmail account, you'll be asked to consent to the Microsoft Power Platform application.

With "Bring your own application" option, you can use your own Google OAuth Client application instead of the one managed by Microsoft. Doing so will allow you to control permissions and enable certain limitations on the use of the connector.

To use your own Google OAuth Client application with the Gmail connector, you'll need to perform the following steps:

  1. Create an OAuth client application using Google's API Console
  2. Use the application in the Gmail connector

Creating an OAuth Client Application in Google

To create your own Google OAuth client application, you'll need to first sign in to https://developer.google.com. Navigate to Google's API Console — which is where you can manage access to Google APIs — and create the OAuth application. This process is explained in Google's Gmail API Developer Guide. Google provides a setup tool to guide you through the process of creating a project for you, enable the Gmail API for your project, and create an OAuth client application and the credentials for it. Here's some information you'll find useful when going through the tool:

  • Read and agree to the Terms of Service if needed.
  • Select an existing project, or the tool will create a new one called "My Project".
  • The tool will enable the Gmail API in the project.
  • The tool will try to find out the credential type you need. You'll need to get an OAuth Client application.
    • Select Gmail API for the API you'll be using (if not already selected).
    • Select Web server for the where you'll be calling the API from.
    • Select User data for the data you'll be accessing.
  • The tool will walk you through the set up an OAuth consent screen.
    • Select the user type (Internal or External). If you are using a Gmail consumer account, you cannot select Internal.
    • Provide a name and, optionally, a logo for your application.
    • Click on Add Scope and add the Gmail scope (https://mail.google.com).

      Note

      Based on your usage need, you can select an appropriate subset of the permission scopes here.

    • Add azure-apim.net as one of the authorized domains.

      Note

      This is the domain on which the Gmail connector is hosted, as defined here.

    • Optionally, provide the other information.
  • The tool will let you define and add an OAuth 2.0 client credential.
    • Provide a name for your OAuth Client application.
    • Add "https://global.consent.azure-apim.net/redirect" for the Redirect URI.

Once you're done, navigate to the created OAuth client from the Credentials page. You'll find the Client ID and the Client secret of your app. You can now use those values in your Gmail connection.

Google OAuth Client

Using your own application in the Gmail connector

Once you create the Google OAuth client application, you can use it while creating a Gmail connection.

  • Select Bring your own application.
  • Specify the Client ID and Client secret values from your application.

Click on Sign in to sign into your Gmail account. This will prompt you to sign in to your Gmail account, and then authorize access to the Google app that you created above.

Known issues and limitations

Trigger limitations for large number of incoming emails

The When a new email arrives trigger may skip emails if you are receiving more than 300 emails per 30 seconds interval. Consider configuring your flow with additional filter parameters to reduce number of emails.

The When a new email arrives trigger may intermittently skip emails with attachments if you are using a Google Workspace (formerly G Suite) account. This happens because in some case Gmail API takes a long time to process emails (possibly due to security scans of attachments), so the emails are received with a certain delay.

As possible workaround please try the following:

  • Use tiny emails (without attachments), try to send them not so frequently

  • Use another consumer Gmail account and configure auto-forwarding from the Google Workspace account to this new consumer Gmail account. Configure the trigger against this new account. Since this is a consumer account, we believe that the delay will be minimized and the trigger will not skip such emails.

  • Use a custom connector to ListMessage API with a q parameter:

    • Create an action to list messages for the last 5 minutes. You can do so using q parameter. Example of q param value - after:1649457986. You should provide current time - 5min epoch time as the action input.

      • 1649457986 is the epoch time that represents "Friday, April 8, 2022 3:46:26 PM GMT-07:00".
    • Check nextPageToken value from the response until it is empty. If it is not empty then you need to call the same API with pageToken parameter value set to the nextPageToken from the response. You can do so using "Until" loop for example.

    • Filter out those messages IDs which have already been processed in previous runs (e.g. you can use Azure Table Storage connector to store already processed IDs)

    • Use Get email details action to get email content by ID

Using Gmail connector with consumer Gmail accounts

In compliance with Google's security and privacy policy, customers using consumer Gmail accounts (Accounts ending in @gmail.com and @googlemail.com) can only connect to a limited set of services within Power Automate and Logic Apps. Customers using Google Workspace (formerly G Suite) accounts are not impacted by this change. If you need to use the Gmail connector with services not specified in the below list you will need to register your own Application id with Google. Below is the list of the current approved services, do note that this list is subject to change in the future in accordance with Google's policies:

  • Google services: Gmail, Google Calendar, Google Contacts, Google Drive, Google Sheets, Google Tasks
  • Built in actions and triggers: Control, AI Builder, Data operations, Date Time, Number Functions, Power Virtual Agents, Power Apps, Request, Schedule, Text Functions, Variables, Flow button, Location
  • Limited set of Microsoft services: OneDrive, Sharepoint, Excel, Dynamics, Microsoft Teams, Office 365, SQL, SFTP and FTP

In Power Automate if you create a flow with a non-compliant service the flow will end up being saved in a disabled state.

Calculating work units

The connector has a throttling limit (refer here) on the number of work units that can be consumed in a day.

The logic on how these work units are calculated for each operation is shown below:

  • When a new email arrives trigger : 10 + (5 * attachmentsCount);
    • If trigger returns new email: 5 units to list messages + 5 units to get message + 5 units * attachments count.
    • If trigger doesn't return new email: 5 units to list messages.
  • Send email (V2) action : 100 units.
  • Reply to email (V2) action : 105 + (5 * attachmentsCount);
    • 5 units to get original message + 100 units to send reply message + 5 units * inline attachments count in original message.
  • For all other actions: 10 units.

Connector in-depth

For more information about the connector, see the in-depth section.

General Limits

Name Value
Maximum mail size (in MB) 35
Maximum attachment size (in MB) 30

Creating a connection

The connector supports the following authentication types:

Bring your own application Sign in using your own Google app. For more details see https://docs.microsoft.com/connectors/gmail/#authentication-and-bring-your-own-application. All regions Not shareable
Use default shared application Sign in using the standard Google app. All regions Not shareable
Default [DEPRECATED] This option is only for older connections without an explicit authentication type, and is only provided for backward compatibility. All regions Not shareable

Bring your own application

Auth ID: byoa

Applicable: All regions

Sign in using your own Google app. For more details see https://docs.microsoft.com/connectors/gmail/#authentication-and-bring-your-own-application.

This is not shareable connection. If the power app is shared with another user, another user will be prompted to create new connection explicitly.

Name Type Description Required
Client ID string Client (or Application) ID of your Google application True
Client Secret securestring Client secret of your Google application True

Use default shared application

Auth ID: shared-application

Applicable: All regions

Sign in using the standard Google app.

This is not shareable connection. If the power app is shared with another user, another user will be prompted to create new connection explicitly.

Default [DEPRECATED]

Applicable: All regions

This option is only for older connections without an explicit authentication type, and is only provided for backward compatibility.

This is not shareable connection. If the power app is shared with another user, another user will be prompted to create new connection explicitly.

Throttling Limits

Name Calls Renewal Period
API calls per connection 60 60 seconds
Work units per day 90000 86400 seconds

Actions

Delete email

This operation is used to delete a specific email permanently.

Get email details

This operation retrieves the details of a specific email.

Move email to trash

This operation is used to move a specific email to trash.

Reply to email (V2)

This operation is used to reply to a specific email.

Reply to email [DEPRECATED]

This action has been deprecated. Please use Reply to email (V2) instead.

This operation is used to reply to a specific email.

Send email (V2)

This operation is used to send an email to specific recipients.

Send email [DEPRECATED]

This action has been deprecated. Please use Send email (V2) instead.

This operation is used to send an email to specific recipients.

Delete email

This operation is used to delete a specific email permanently.

Parameters

Name Key Required Type Description
Message ID
id True string

Id of the email to delete.

Get email details

This operation retrieves the details of a specific email.

Parameters

Name Key Required Type Description
Message ID
id True string

Unique id of the email message.

Include Attachments
includeAttachments boolean

If set to true, attachments will also be retrieved along with the email.

Returns

Details associated with a specific email message.

Move email to trash

This operation is used to move a specific email to trash.

Parameters

Name Key Required Type Description
Message ID
id True string

ID of the email to move to the trash.

Reply to email (V2)

This operation is used to reply to a specific email.

Parameters

Name Key Required Type Description
Message ID
id True string

Id of the email to reply to.

To
To email

Example: recipient1@domain.com; recipient2@domain.com

CC
Cc email

Example: recipient1@domain.com; recipient2@domain.com

BCC
Bcc email

Example: recipient1@domain.com; recipient2@domain.com

Subject
Subject string

Email subject (if empty, the original subject used).

Body
Body html

Content of the email.

Reply All
ReplyAll boolean

True to reply to all recipients. (default: False)

Importance
Importance string

Pick an importance. (default: Normal)

Name
Name True string

Title of the attachment.

Content
ContentBytes True byte

Body of the attachment.

Content-Type
ContentType string

Type of content in the attachment.

Reply to email [DEPRECATED]

This action has been deprecated. Please use Reply to email (V2) instead.

This operation is used to reply to a specific email.

Parameters

Name Key Required Type Description
Message ID
id True string

Id of the email to reply to.

To
To email

Example: recipient1@domain.com; recipient2@domain.com

CC
Cc email

Example: recipient1@domain.com; recipient2@domain.com

BCC
Bcc email

Example: recipient1@domain.com; recipient2@domain.com

Subject
Subject string

Email subject (if empty, the original subject used).

Body
Body string

Content of the email.

Reply All
ReplyAll boolean

True to reply to all recipients. (default: False)

Is HTML
IsHtml boolean

True to send the reply as HTML. (default: True)

Importance
Importance string

Pick an importance. (default: Normal)

Name
Name True string

Title of the attachment.

Content
ContentBytes True byte

Body of the attachment.

Content-Type
ContentType string

Type of content in the attachment.

Send email (V2)

This operation is used to send an email to specific recipients.

Parameters

Name Key Required Type Description
To
To True email

A list of valid email addresses separated by a semicolon or a comma.

CC
Cc email

A list of valid email addresses separated by a semicolon or a comma.

BCC
Bcc email

A list of valid email addresses separated by a semicolon or a comma.

Subject
Subject string

Subject of the outgoing email.

Body
Body html

Body of the outgoing email.

Importance
Importance string

Importance associated with the email message.

Name
Name True string

Title of the attachment.

Content
ContentBytes True byte

Body of the attachment.

Content-Type
ContentType string

Type of content in the attachment.

Send email [DEPRECATED]

This action has been deprecated. Please use Send email (V2) instead.

This operation is used to send an email to specific recipients.

Parameters

Name Key Required Type Description
To
To True email

A list of valid email addresses separated by a semicolon or a comma.

CC
Cc email

A list of valid email addresses separated by a semicolon or a comma.

BCC
Bcc email

A list of valid email addresses separated by a semicolon or a comma.

Subject
Subject string

Subject of the outgoing email.

Body
Body string

Body of the outgoing email.

Is HTML
IsHtml boolean

True to send the email as HTML. (default: True)

Importance
Importance string

Importance associated with the email message.

Name
Name True string

Title of the attachment.

Content
ContentBytes True byte

Body of the attachment.

Content-Type
ContentType string

Type of content in the attachment.

Triggers

When a new email arrives

This operation triggers when a new email matching the specified criteria arrives.

When a new email arrives

This operation triggers when a new email matching the specified criteria arrives.

Parameters

Name Key Required Type Description
Label
label string

Pick a label (default: Inbox).

To
to email

A list of valid email addresses separated by a semicolon or a comma.

From
from email

Example: Sender1 | sender2@domain.com.

Subject
subject string

String to look for in the subject.

Importance
importance string

True if the email should be important. (default: All).

Starred
starred string

True if the email should be starred. (default: All).

Has Attachments
fetchOnlyWithAttachments boolean

True to retrieve only emails with attachments.

Include Attachments
includeAttachments boolean

True to retrieve attachments along with the email.

Returns

Details associated with a specific email message.

Definitions

DetailedReceiveMessage

Details associated with a specific email message.

Name Path Type Description
From
From email

Email address the message was sent from.

Sender's Name
SenderName string

Email sender's name

To
To email

Email address the message was sent to.

CC
Cc email

Email addresses contained in the CC field.

BCC
Bcc email

Email addresses contained in the BCC field.

Subject
Subject string

Subject or topic associated with the email message.

Body
Body string

Content of the email message.

Snippet
Snippet string

A short part of the message text.

Label IDs
LabelIds array of string

List of labels associated with the email message.

Received Date-Time
DateTimeReceived date-time

Example:2017-05-03T20:08:57+00:00

Estimated Size
EstimatedSize integer

Estimated size in bytes of the message.

Is Read?
IsRead boolean

True if the message is read; false otherwise.

Is HTML
IsHtml boolean

True if the message is in HTML format.

Has Attachments
HasAttachments boolean

True if the message has attachments.

Attachments
Attachments array of Attachment

List of attachments to the email message.

Message ID
Id string

The immutable ID of the message.

Thread ID
ThreadId string

The ID of the thread the message belongs to.

Attachment

Properties of an email attachment.

Name Path Type Description
Name
Name string

Title of the attachment.

Content
ContentBytes byte

Body of the attachment.

Content-Type
ContentType string

Type of content in the attachment.