Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/Gmail/Gmail_Update_email_flag.ipynb
2973 views
Kernel: Python 3

Gmail.jpg

Gmail - Update email flag

Give Feedback | Bug report

Tags: #gmail #productivity #naas_drivers #operations #snippet #dataframe

Last update: 2023-05-12 (Created: 2023-05-12)

Description: This notebook allows you to update an email flag in your Gmail inbox.

Input

Import librairy

import naas from naas_drivers import email

Setup Variables

Create an application password following this procedure

  • username: This variable stores the username or email address associated with the email account

  • password: This variable stores the password or authentication token required to access the email account

  • smtp_server: This variable represents the SMTP server address used for sending emails.

  • box: This variable stores the name or identifier of the mailbox or folder within the email account that will be accessed.

  • uid: Unique email ID to be updated. You can it by reading your mailbox.

  • flag: possible value for flag: 'SEEN', 'ANSWERED', 'FLAGGED', 'DELETED', 'DRAFT', 'RECENT'

# Inputs username = "xxxxx@xxxxx" password = naas.secret.get("GMAIL_APP_PASSWORD") or "xxxxxxxx" smtp_server = "imap.gmail.com" box = "INBOX" # Outputs uid = "7907" flag = "SEEN"

Model

Connect to email box

emails = email.connect(username, password, smtp_server=smtp_server)

Output

Update email status

emails.set_flag(uid, flag)