Stay organized with collections Save and categorize content based on your preferences.
Gmail
This Service lets you send email, compose drafts, manage labels, mark messages and threads, and conduct a variety of other Gmail account management tasks. See also Mail Service, a simpler service that only allows the sending of email.
Classes Name Brief descriptionGmailApp
Provides access to Gmail threads, messages, and labels. GmailAttachment
An attachment from Gmail. GmailDraft
A user-created draft message in a user's Gmail account. GmailLabel
A user-created label in a user's Gmail account. GmailMessage
A message in a user's Gmail account. GmailThread
A thread in a user's Gmail account. GmailApp
Methods Method Return type Brief description createDraft(recipient, subject, body)
GmailDraft
Creates a draft email message. createDraft(recipient, subject, body, options)
GmailDraft
Creates a draft email message with optional arguments. createLabel(name)
GmailLabel
Create a new user label of the given name. deleteLabel(label)
GmailApp
Deletes the specified label. getAliases()
String[]
Gets a list of the emails that are set up as aliases for this account in Gmail. getDraft(draftId)
GmailDraft
Retrieve an email message draft by ID. getDraftMessages()
GmailMessage[]
Retrieves all draft messages. getDrafts()
GmailDraft[]
Gets all Gmail draft messages. getInboxThreads()
GmailThread[]
Retrieves all Inbox threads irrespective of labels. getInboxThreads(start, max)
GmailThread[]
Retrieves a range of Inbox threads irrespective of labels. getInboxUnreadCount()
Integer
Gets the number of unread threads in the inbox. getMessageById(id)
GmailMessage
Gets a message by ID. getMessagesForThread(thread)
GmailMessage[]
Retrieve all messages in the specified thread. getMessagesForThreads(threads)
GmailMessage[][]
Retrieve all messages in the specified threads. getPriorityInboxThreads()
GmailThread[]
Retrieves all Priority Inbox threads irrespective of labels. getPriorityInboxThreads(start, max)
GmailThread[]
Retrieves a range of Priority Inbox threads irrespective of labels. getPriorityInboxUnreadCount()
Integer
Gets the number of unread threads in the Priority Inbox. getSpamThreads()
GmailThread[]
Retrieves all spam threads irrespective of labels. getSpamThreads(start, max)
GmailThread[]
Retrieves a range of spam threads irrespective of labels. getSpamUnreadCount()
Integer
Gets the number of unread threads that are spam. getStarredThreads()
GmailThread[]
Retrieves all starred threads irrespective of labels. getStarredThreads(start, max)
GmailThread[]
Retrieves a range of starred threads irrespective of labels. getStarredUnreadCount()
Integer
Gets the number of unread threads that are starred. getThreadById(id)
GmailThread
Gets a thread by ID. getTrashThreads()
GmailThread[]
Retrieves all trash threads irrespective of labels. getTrashThreads(start, max)
GmailThread[]
Retrieves a range of trash threads irrespective of labels. getUserLabelByName(name)
GmailLabel
Retrieves a label given the label name. getUserLabels()
GmailLabel[]
Retrieves a list of user-created labels. markMessageRead(message)
GmailApp
Marks this message read and forces the message to refresh. markMessageUnread(message)
GmailApp
Marks this message unread and forces the message to refresh. markMessagesRead(messages)
GmailApp
Marks these messages read and forces the messages to refresh. markMessagesUnread(messages)
GmailApp
Marks these messages unread and forces the messages to refresh. markThreadImportant(thread)
GmailApp
Marks this thread as important and forces the thread to refresh. markThreadRead(thread)
GmailApp
Marks this thread as read and forces the thread to refresh. markThreadUnimportant(thread)
GmailApp
Marks this thread as unimportant and forces the thread to refresh. markThreadUnread(thread)
GmailApp
Marks this thread unread and forces the thread to refresh. markThreadsImportant(threads)
GmailApp
Marks these threads as important and forces the threads to refresh. markThreadsRead(threads)
GmailApp
Marks these threads as read and forces the threads to refresh. markThreadsUnimportant(threads)
GmailApp
Marks these threads as unimportant and forces the threads to refresh. markThreadsUnread(threads)
GmailApp
Marks these threads as unread and forces the threads to refresh. moveMessageToTrash(message)
GmailApp
Moves the message to the trash and forces the message to refresh. moveMessagesToTrash(messages)
GmailApp
Moves the specified messages to the trash and forces the messages to refresh. moveThreadToArchive(thread)
GmailApp
Moves this thread to the archive and forces the thread to refresh. moveThreadToInbox(thread)
GmailApp
Moves this thread to the inbox and forces the thread to refresh. moveThreadToSpam(thread)
GmailApp
Moves this thread to spam and forces the thread to refresh. moveThreadToTrash(thread)
GmailApp
Moves this thread to the trash and forces the thread to refresh. moveThreadsToArchive(threads)
GmailApp
Moves these threads to the archive and forces the threads to refresh. moveThreadsToInbox(threads)
GmailApp
Moves these threads to the inbox and forces the threads to refresh. moveThreadsToSpam(threads)
GmailApp
Moves these threads to spam and forces the threads to refresh. moveThreadsToTrash(threads)
GmailApp
Moves these threads to the trash and forces the threads to refresh. refreshMessage(message)
GmailApp
Reloads the message and associated state from Gmail (useful in case the labels, read state, etc., have changed). refreshMessages(messages)
GmailApp
Reloads the messages and associated state from Gmail (useful in case the labels, read state, etc., have changed). refreshThread(thread)
GmailApp
Reloads the thread and associated state from Gmail (useful in case the labels, read state, etc., have changed). refreshThreads(threads)
GmailApp
Reloads the threads and associated state from Gmail (useful in case the labels, read state, etc., have changed). search(query)
GmailThread[]
Search Gmail with the given query. search(query, start, max)
GmailThread[]
Search Gmail with the given query. sendEmail(recipient, subject, body)
GmailApp
Sends an email message. sendEmail(recipient, subject, body, options)
GmailApp
Sends an email message with optional arguments. setCurrentMessageAccessToken(accessToken)
void
Sets the current message access token that enables the script to access the current GmailMessage
properties. starMessage(message)
GmailApp
Adds a star to this message and forces the message to refresh. starMessages(messages)
GmailApp
Adds stars to these messages and forces the messages to refresh. unstarMessage(message)
GmailApp
Removes a star from this message and forces the message to refresh. unstarMessages(messages)
GmailApp
Removes stars from these messages and forces the messages to refresh. GmailAttachment
GmailDraft
GmailLabel
GmailMessage
Methods Method Return type Brief description createDraftReply(body)
GmailDraft
Creates a draft message replying to the sender of this message using the reply-to address. createDraftReply(body, options)
GmailDraft
Creates a draft message replying to the sender of this message using the reply-to address, with optional arguments. createDraftReplyAll(body)
GmailDraft
Creates a draft message replying to the sender using the reply-to address and all recipients of this message. createDraftReplyAll(body, options)
GmailDraft
Creates a draft message replying to the sender of this message using the reply-to address and all recipients, with optional arguments. forward(recipient)
GmailMessage
Forwards this message to new recipients. forward(recipient, options)
GmailMessage
Forwards this message to new recipients, with optional arguments. getAttachments()
GmailAttachment[]
Gets all the attachments for this message. getAttachments(options)
GmailAttachment[]
Gets all the attachments for this message. getBcc()
String
Gets the comma-separated recipients bcc'd on this message. getBody()
String
Gets the HTML content of the body of this message. getCc()
String
Gets the comma-separated recipients cc'd on this message. getDate()
Date
Gets the date and time of this message. getFrom()
String
Gets the sender of this message. getHeader(name)
String
Gets the value of an RFC 2822 header given the header name. getId()
String
Gets the ID of this message. getPlainBody()
String
Gets the content of the body of this message without HTML formatting. getRawContent()
String
Gets the raw content of this message. getReplyTo()
String
Gets the reply-to address of this message (usually the sender). getSubject()
String
Gets the subject of this message. getThread()
GmailThread
Gets the thread that contains this message. getTo()
String
Gets the comma-separated recipients of this message. isDraft()
Boolean
Gets whether this message is a draft. isInChats()
Boolean
Gets whether this message is a chat. isInInbox()
Boolean
Gets whether this message is in the inbox. isInPriorityInbox()
Boolean
Returns true
if this message is in the priority inbox; returns false
otherwise. isInTrash()
Boolean
Gets whether this message is in the trash. isStarred()
Boolean
Gets whether this message is starred. isUnread()
Boolean
Gets whether this message is unread. markRead()
GmailMessage
Marks the message as read. markUnread()
GmailMessage
Marks the message as unread. moveToTrash()
GmailMessage
Moves the message to the trash. refresh()
GmailMessage
Reloads this message and associated state from Gmail (useful in case the labels, read state, etc., have changed). reply(body)
GmailMessage
Replies to the sender of this message using the reply-to address. reply(body, options)
GmailMessage
Replies to the sender of this message using the reply-to address, with optional arguments. replyAll(body)
GmailMessage
Replies to the sender using the reply-to address and all recipients of this message. replyAll(body, options)
GmailMessage
Replies to the sender of this message using the reply-to address and all recipients, with optional arguments. star()
GmailMessage
Stars the message. unstar()
GmailMessage
Unstars the message. GmailThread
Methods Method Return type Brief description addLabel(label)
GmailThread
Adds this label to the thread. createDraftReply(body)
GmailDraft
Creates a draft message replying to the sender of the last message in this thread using the reply-to address. createDraftReply(body, options)
GmailDraft
Creates a draft message replying to the sender of the last message in this thread using the reply-to address, with optional arguments. createDraftReplyAll(body)
GmailDraft
Creates a draft message replying to the sender of the last message in this thread, using the reply-to address and all recipients of this message. createDraftReplyAll(body, options)
GmailDraft
Creates a draft message replying to the sender of the last message in this thread, using the reply-to address and all recipients, with optional arguments. getFirstMessageSubject()
String
Gets the subject of the first message in the thread. getId()
String
Gets the ID of this thread. getLabels()
GmailLabel[]
Returns the user-created labels on this thread. getLastMessageDate()
Date
Gets the date of this thread's most recent message. getMessageCount()
Integer
Returns the number of messages in the thread. getMessages()
GmailMessage[]
Gets the messages in this thread. getPermalink()
String
Gets a permalink for this thread. hasStarredMessages()
Boolean
Returns whether the thread has any starred messages. isImportant()
Boolean
Returns whether the thread is marked as important. isInChats()
Boolean
Returns whether the thread is labeled a chat. isInInbox()
Boolean
Returns whether the thread is in the inbox. isInPriorityInbox()
Boolean
Returns true if this thread is in the priority inbox; returns false otherwise. isInSpam()
Boolean
Returns whether the thread is marked as spam. isInTrash()
Boolean
Returns whether the thread is in the trash. isUnread()
Boolean
Returns whether the thread has any unread messages. markImportant()
GmailThread
Marks this thread as important. markRead()
GmailThread
Marks this thread as read. markUnimportant()
GmailThread
Marks this thread as unimportant. markUnread()
GmailThread
Marks this thread as unread. moveToArchive()
GmailThread
Moves this thread to the archive. moveToInbox()
GmailThread
Moves this thread to the inbox. moveToSpam()
GmailThread
Moves this thread to spam. moveToTrash()
GmailThread
Moves this thread to the trash. refresh()
GmailThread
Reloads this thread, and associated state from Gmail (useful in case the labels, read state, etc., have changed). removeLabel(label)
GmailThread
Removes this label from the thread. reply(body)
GmailThread
Reply to the sender of the last message on this thread using the replyTo address. reply(body, options)
GmailThread
Reply to the sender of the last message on this thread using the replyTo address, with optional arguments. replyAll(body)
GmailThread
Reply to the sender (using the replyTo address), and all recipients of the last message on this thread. replyAll(body, options)
GmailThread
Reply to the sender (using the replyTo
address), and all recipients of the last message on this thread, with optional arguments.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-04 UTC."],[[["The Gmail service in Google Apps Script allows for comprehensive management of Gmail accounts, including sending emails, managing drafts, labels, and messages."],["The `GmailApp` class provides access to various Gmail functionalities, such as creating drafts, managing labels, searching emails, and retrieving threads."],["`GmailThread` and `GmailMessage` objects offer methods to interact with email threads and individual messages respectively, including marking them as read, starring, moving them to different folders, and replying to them."],["You can use dedicated classes like `GmailAttachment`, `GmailDraft`, and `GmailLabel` to work with email attachments, drafts, and labels respectively."],["The service offers methods to search for emails based on queries and to manage spam, starred, priority inbox, and trash threads."]]],["Gmail enables users to manage emails, drafts, and labels. Key actions include creating and managing labels with `createLabel` and `deleteLabel`, retrieving them with `getUserLabelByName`, and listing all labels with `getUserLabels`. It also allows creating drafts via `createDraft`, managing threads using methods like `getInboxThreads` and managing message using methods like `getMessageById`. Users can search with `search`, send emails with `sendEmail`, mark messages/threads as read/unread, and move them to the trash/spam/archive. Attachment data can be read/write with methods such as `getBytes` and `setBytes`.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4