Like its cousin, the exchange box connector, the idea is to create a wrapper that will enable a Melusine user to connect to his gmail box and analyze it. Starting from the exchange connector, most of the methods have been adapted to move in the same direction. The gmail box works slightly differently. There are no folders as such, but rather labels, which function like views. The INBOX label corresponds to the complete mailbox, TRASH to the garbage... Users can create new labels. The Gmail connector lets you connect, read e-mails with a label and date filter, move them around, extract relevant information into a pandas dataframe that can be used by Melusine, and send e-mails.
Fixes #174
Type of change
[X] New feature (non-breaking change which adds functionality or feature that would cause existing functionality to not work as expected)
[X] This change requires a documentation update -> Advanced?
How Has This Been Tested?
I Implemented all unit tests for GmailConnector. To test with your own mailbox, please follow these steps:
copy paste your credentials.json into the root folder of the repo
then you can test with:
from melusine.connectors.gmail import GmailConnector
gc = GmailConnector(done_label="test")
Follow instructions to connect to the right mailbox. Please make sure while following the medium post that this email is in the allowed testing emails.
```python
df = gc.get_emails(5)
gc.create_label("USECASE1")
gc.create_label("USECASE2")
df["target"] = ["INBOX", "TRASH", "USECASE1", "USECASE2", "TRASH"]
gc.route_emails(df)
gc.move_to_done([df.iloc[0]["message_id"]])
Description
Like its cousin, the exchange box connector, the idea is to create a wrapper that will enable a Melusine user to connect to his gmail box and analyze it. Starting from the exchange connector, most of the methods have been adapted to move in the same direction. The gmail box works slightly differently. There are no folders as such, but rather labels, which function like views. The INBOX label corresponds to the complete mailbox, TRASH to the garbage... Users can create new labels. The Gmail connector lets you connect, read e-mails with a label and date filter, move them around, extract relevant information into a pandas dataframe that can be used by Melusine, and send e-mails.
Fixes #174
Type of change
How Has This Been Tested?
I Implemented all unit tests for
GmailConnector
. To test with your own mailbox, please follow these steps:follow the installation part from this medium post: https://medium.com/@preetipriyanka24/how-to-read-emails-from-gmail-using-gmail-api-in-python-20f7d9d09ae9
copy paste your
credentials.json
into the root folder of the repothen you can test with:
gc = GmailConnector(done_label="test")
Test Configuration:
Checklist: