Thanks for this repo! It has made it very easy to connect to my email account.
Although, I have been successful in executing all the functions, what I can't figure out is can I have multiple accounts? For example, can I authenticate [email protected] as well as [email protected] and have them run the same python script? This is a simple script to delete emails from specific email addresses. I would like to use this on multiple gmail accounts.
import google_workspace
import sys
import mail_support
service = google_workspace.service.GoogleService(
api="gmail",
session="my-gmail",
client_secrets="/home/ubuntu/credentials/credentials.json"
)
service.local_oauth()
gmail_client = google_workspace.gmail.GmailClient(service=service)
print(gmail_client.email_address)
spam_list = mail_support.get_spam()
for message in gmail_client.get_messages("inbox"):
if message.from_ in spam_list:
print("------------->")
print((message.message_data['id']))
print((message))
print("------------->")
x= message.message_data['id']
gmail_client.delete_message(x)