- 1 Introduction to get Gmail with REST API
- 2 Requirements
- 3 Getting started
- 4 Conclusion
- 5 References
Introduction to get Gmail with REST API
In this example, we will show how to read emails by calling Gmail REST API using SSIS. To illustrate, we will use ZappySys SSIS PowerPack, which includes several tasks to import/export data from multiples sources to multiple destinations like flat files, Azure, AWS, databases, Office files and more.
- First, you will need ZappySys SSIS PowerPack installed.
- Secondly, you will need SSDT installed.
How to get information about Gmail with REST API
- First, you will need to create a developer application for Gmail. The following tutorial shows how to create an application for Google Drive, but the steps are similar:
- Secondly, go to SSDT and create a new SQL Server Integration Project.
- Subsequently, drag and drop a Data Flow task and double-click it:
- Also, in the connection manager create a new ZS-OAuth connection. Select Google as the OAuth provider. In scopes, add the following:
- To illustrate, the following example shows how to get the Gmail messages from an account. Check the option use credentials and select the OAuth connection just created. To get your current email messages, you can use the following URL:
The filter used is the following:1$.messages[*].id
The result displayed shows the ids of the messages. You can see the id of the message in Gmail in the URL when you click a message:
- If you want to check to information of a specific message you can use the following URL.
Where 1632106341364d6f is the message id. The filter used will be the following:1$.id
The query shows the snippet (body of the message), the history id, size estimated and more.
- After this, we can use the following filter:
This will show the sender, the receiver, subject, references, message ID and more information:
How to get label information in Gmail with REST API
- First, you can use the following URL to get the Gmail labels:
- Also, the information displayed is the following:
- Finally, the labels are the same than in Gmail:
How to get threads information in Gmail with REST API
- Finally, you can also get the thread information using the following URL:
- The information displayed will be the following:
- If you press the Preview button, you will see the following information:
How to export the data from Gmail to a CSV file
- First, to export the data, we will use the ZS Trash Destination:
- Finally, in the Trash Destination specify the path to store the data from Gmail:
To conclude, we can say that ZappySys SSIS PowerPack is a powerful tool where you can get information from Gmail. This information can be exported to Excel, SQL Server, XML, JSON or any other format using SSIS. Download FREE Trial of SSIS PowerPack to find out more use cases like this.
For more information about Gmail, you can refer to these links: