Gmail API Reference
Complete reference for all Gmail service methods and properties.
Gmail Class
pythonfrom gspace import GSpace gspace = GSpace.from_oauth(credentials_file, scopes=["gmail"]) gmail = gspace.gmail()
Methods
send_simple_email
Send a simple text email.
pythondef send_simple_email( to: str | list[str], subject: str, body: str, cc: str | list[str] | None = None, bcc: str | list[str] | None = None ) -> dict
Parameters:
to(str | list[str]): Recipient email address(es)subject(str): Email subjectbody(str): Email body textcc(str | list[str], optional): CC recipientsbcc(str | list[str], optional): BCC recipients
Returns: Sent message dictionary
send_email
Send an email with attachments and advanced options.
pythondef send_email( to: str | list[str], subject: str, body: str, attachments: list[str] | None = None, cc: str | list[str] | None = None, bcc: str | list[str] | None = None, html_body: str | None = None ) -> dict
get_message
Get a specific message by ID.
pythondef get_message(message_id: str) -> dict
list_messages
List messages from the mailbox.
pythondef list_messages( query: str | None = None, max_results: int = 10, page_token: str | None = None ) -> list[dict]
search_messages
Search for messages using Gmail search syntax.
pythondef search_messages( query: str, max_results: int = 10 ) -> list[dict]
delete_message
Delete a message.
pythondef delete_message(message_id: str) -> None
list_labels
List all labels.
pythondef list_labels() -> list[dict]
create_label
Create a new label.
pythondef create_label( name: str, label_list_visibility: str = "labelShow" ) -> dict
add_label
Add a label to a message.
pythondef add_label(message_id: str, label_id: str) -> dict
remove_label
Remove a label from a message.
pythondef remove_label(message_id: str, label_id: str) -> dict
create_draft
Create a draft message.
pythondef create_draft( to: str | list[str], subject: str, body: str ) -> dict
send_draft
Send a draft message.
pythondef send_draft(draft_id: str) -> dict