How to check if a mail is read in gmail

There are a few ways to check if a mail is read in Gmail:

Method 1: Check the "Read" status in the Gmail inbox

  1. Log in to your Gmail account.
  2. Go to your inbox.
  3. Find the email you want to check.
  4. Look for the "Read" status indicator next to the email subject. If it's checked, the email has been read. If it's unchecked, the email has not been read.

Method 2: Check the "Viewed" timestamp

  1. Log in to your Gmail account.
  2. Go to your inbox.
  3. Find the email you want to check.
  4. Click on the email to open it.
  5. Look for the "Viewed" timestamp at the top of the email. If it's present, it means the email has been read.

Method 3: Use the Gmail API

If you're building a custom application or script, you can use the Gmail API to check if an email has been read. You'll need to:

  1. Enable the Gmail API in the Google Cloud Console.
  2. Use the Gmail API to retrieve the email metadata.
  3. Check the viewed property in the email metadata. If it's true, the email has been read.

Here's an example of how to use the Gmail API to check if an email has been read using Python:

import google.auth
from googleapiclient.discovery import build

# Set up authentication
creds, project = google.auth.default(scopes=['https://www.googleapis.com/auth/gmail.readonly'])

# Create the Gmail API client
service = build('gmail', 'v1', credentials=creds)

# Set the email ID
email_id = '[email protected]'

# Retrieve the email metadata
response = service.users().messages().get(userId='me', id=email_id).execute()

# Check if the email has been read
if response['payload']['headers'][0]['viewed']:
    print('Email has been read')
else:
    print('Email has not been read')

Note that the Gmail API requires authentication and has usage limits, so be sure to review the documentation and terms of service before using it in your application.