Debian Codegraph @

docs/dyn/gmail_v1.users.messages.html

raw
1 <html><body>
2 <style>
3
4 body, h1, h2, h3, div, span, p, pre, a {
5 margin: 0;
6 padding: 0;
7 border: 0;
8 font-weight: inherit;
9 font-style: inherit;
10 font-size: 100%;
11 font-family: inherit;
12 vertical-align: baseline;
13 }
14
15 body {
16 font-size: 13px;
17 padding: 1em;
18 }
19
20 h1 {
21 font-size: 26px;
22 margin-bottom: 1em;
23 }
24
25 h2 {
26 font-size: 24px;
27 margin-bottom: 1em;
28 }
29
30 h3 {
31 font-size: 20px;
32 margin-bottom: 1em;
33 margin-top: 1em;
34 }
35
36 pre, code {
37 line-height: 1.5;
38 font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace;
39 }
40
41 pre {
42 margin-top: 0.5em;
43 }
44
45 h1, h2, h3, p {
46 font-family: Arial, sans serif;
47 }
48
49 h1, h2, h3 {
50 border-bottom: solid #CCC 1px;
51 }
52
53 .toc_element {
54 margin-top: 0.5em;
55 }
56
57 .firstline {
58 margin-left: 2 em;
59 }
60
61 .method {
62 margin-top: 1em;
63 border: solid 1px #CCC;
64 padding: 1em;
65 background: #EEE;
66 }
67
68 .details {
69 font-weight: bold;
70 font-size: 14px;
71 }
72
73 </style>
74
75 <h1><a href="gmail_v1.html">Gmail API</a> . <a href="gmail_v1.users.html">users</a> . <a href="gmail_v1.users.messages.html">messages</a></h1>
76 <h2>Instance Methods</h2>
77 <p class="toc_element">
78 <code><a href="gmail_v1.users.messages.attachments.html">attachments()</a></code>
79 </p>
80 <p class="firstline">Returns the attachments Resource.</p>
81
82 <p class="toc_element">
83 <code><a href="#batchDelete">batchDelete(userId, body=None, x__xgafv=None)</a></code></p>
84 <p class="firstline">Deletes many messages by message ID. Provides no guarantees that messages were not already deleted or even existed at all.</p>
85 <p class="toc_element">
86 <code><a href="#batchModify">batchModify(userId, body=None, x__xgafv=None)</a></code></p>
87 <p class="firstline">Modifies the labels and the Classification Label values on the specified messages. For administrators modifying messages for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.modify.restricted` scope.</p>
88 <p class="toc_element">
89 <code><a href="#close">close()</a></code></p>
90 <p class="firstline">Close httplib2 connections.</p>
91 <p class="toc_element">
92 <code><a href="#delete">delete(userId, id, x__xgafv=None)</a></code></p>
93 <p class="firstline">Immediately and permanently deletes the specified message. This operation cannot be undone. Prefer `messages.trash` instead.</p>
94 <p class="toc_element">
95 <code><a href="#get">get(userId, id, format=None, metadataHeaders=None, x__xgafv=None)</a></code></p>
96 <p class="firstline">Gets the specified message.</p>
97 <p class="toc_element">
98 <code><a href="#import_">import_(userId, body=None, deleted=None, internalDateSource=None, media_body=None, media_mime_type=None, neverMarkSpam=None, processForCalendar=None, x__xgafv=None)</a></code></p>
99 <p class="firstline">Imports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. This method doesn't perform SPF checks, so it might not work for some spam messages, such as those attempting to perform domain spoofing. This method does not send a message. Note that the maximum size of the message is 150 MB.</p>
100 <p class="toc_element">
101 <code><a href="#insert">insert(userId, body=None, deleted=None, internalDateSource=None, media_body=None, media_mime_type=None, x__xgafv=None)</a></code></p>
102 <p class="firstline">Directly inserts a message into only this user's mailbox similar to `IMAP APPEND`, bypassing most scanning and classification. Does not send a message. For more information, see [Create and send email messages](https://developers.google.com/workspace/gmail/api/guides/sending).</p>
103 <p class="toc_element">
104 <code><a href="#list">list(userId, includeSpamTrash=None, labelIds=None, maxResults=None, pageToken=None, q=None, x__xgafv=None)</a></code></p>
105 <p class="firstline">Lists the messages in the user's mailbox. For more information, see [List Gmail messages](https://developers.google.com/workspace/gmail/api/guides/list-messages).</p>
106 <p class="toc_element">
107 <code><a href="#list_next">list_next()</a></code></p>
108 <p class="firstline">Retrieves the next page of results.</p>
109 <p class="toc_element">
110 <code><a href="#modify">modify(userId, id, body=None, x__xgafv=None)</a></code></p>
111 <p class="firstline">Modifies the labels and the Classification Label values on the specified message. For administrators modifying message for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.modify.restricted` scope.</p>
112 <p class="toc_element">
113 <code><a href="#send">send(userId, body=None, media_body=None, media_mime_type=None, x__xgafv=None)</a></code></p>
114 <p class="firstline">Sends the specified message to the recipients in the `To`, `Cc`, and `Bcc` headers. For more information, see [Create and send email messages](https://developers.google.com/workspace/gmail/api/guides/sending).</p>
115 <p class="toc_element">
116 <code><a href="#trash">trash(userId, id, x__xgafv=None)</a></code></p>
117 <p class="firstline">Moves the specified message to the trash.</p>
118 <p class="toc_element">
119 <code><a href="#untrash">untrash(userId, id, x__xgafv=None)</a></code></p>
120 <p class="firstline">Removes the specified message from the trash.</p>
121 <h3>Method Details</h3>
122 <div class="method">
123 <code class="details" id="batchDelete">batchDelete(userId, body=None, x__xgafv=None)</code>
124 <pre>Deletes many messages by message ID. Provides no guarantees that messages were not already deleted or even existed at all.
125
126 Args:
127 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
128 body: object, The request body.
129 The object takes the form of:
130
131 {
132 &quot;ids&quot;: [ # The IDs of the messages to delete.
133 &quot;A String&quot;,
134 ],
135 }
136
137 x__xgafv: string, V1 error format.
138 Allowed values
139 1 - v1 error format
140 2 - v2 error format
141 </pre>
142 </div>
143
144 <div class="method">
145 <code class="details" id="batchModify">batchModify(userId, body=None, x__xgafv=None)</code>
146 <pre>Modifies the labels and the Classification Label values on the specified messages. For administrators modifying messages for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.modify.restricted` scope.
147
148 Args:
149 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
150 body: object, The request body.
151 The object takes the form of:
152
153 {
154 &quot;addClassificationLabels&quot;: [ # A list of Classification Label values to add. If a Classification Label with the same label ID is already applied to the message, fields with existing field IDs will be updated and fields with new field IDs will be added. There&#x27;s a limit of 20 Classification Label values per request. If the message is already classified and the final total number of Classification Label values exceeds the maximum allowed number of Classification Label values per message, the modification fails.
155 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
156 &quot;fields&quot;: [ # Field values for the given classification label ID.
157 { # Field values for a classification label.
158 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
159 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
160 },
161 ],
162 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
163 },
164 ],
165 &quot;addLabelIds&quot;: [ # A list of label IDs to add to messages.
166 &quot;A String&quot;,
167 ],
168 &quot;ids&quot;: [ # The IDs of the messages to modify. There is a limit of 1000 ids per request.
169 &quot;A String&quot;,
170 ],
171 &quot;removeClassificationLabelIds&quot;: [ # A list of Classification Label values to remove from messages.
172 &quot;A String&quot;,
173 ],
174 &quot;removeLabelIds&quot;: [ # A list of label IDs to remove from messages.
175 &quot;A String&quot;,
176 ],
177 }
178
179 x__xgafv: string, V1 error format.
180 Allowed values
181 1 - v1 error format
182 2 - v2 error format
183 </pre>
184 </div>
185
186 <div class="method">
187 <code class="details" id="close">close()</code>
188 <pre>Close httplib2 connections.</pre>
189 </div>
190
191 <div class="method">
192 <code class="details" id="delete">delete(userId, id, x__xgafv=None)</code>
193 <pre>Immediately and permanently deletes the specified message. This operation cannot be undone. Prefer `messages.trash` instead.
194
195 Args:
196 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
197 id: string, The ID of the message to delete. (required)
198 x__xgafv: string, V1 error format.
199 Allowed values
200 1 - v1 error format
201 2 - v2 error format
202 </pre>
203 </div>
204
205 <div class="method">
206 <code class="details" id="get">get(userId, id, format=None, metadataHeaders=None, x__xgafv=None)</code>
207 <pre>Gets the specified message.
208
209 Args:
210 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
211 id: string, The ID of the message to retrieve. This ID is usually retrieved using `messages.list`. The ID is also contained in the result when a message is inserted (`messages.insert`) or imported (`messages.import`). (required)
212 format: string, The format to return the message in.
213 Allowed values
214 minimal - Returns only email message ID and labels; does not return the email headers, body, or payload.
215 full - Returns the full email message data with body content parsed in the `payload` field; the `raw` field is not used. Format cannot be used when accessing the api using the gmail.metadata scope.
216 raw - Returns the full email message data with body content in the `raw` field as a base64url encoded string; the `payload` field is not used. Format cannot be used when accessing the api using the gmail.metadata scope.
217 metadata - Returns only email message ID, labels, and email headers.
218 metadataHeaders: string, When given and format is `METADATA`, only include headers specified. (repeated)
219 x__xgafv: string, V1 error format.
220 Allowed values
221 1 - v1 error format
222 2 - v2 error format
223
224 Returns:
225 An object of the form:
226
227 { # An email message.
228 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
229 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
230 &quot;fields&quot;: [ # Field values for the given classification label ID.
231 { # Field values for a classification label.
232 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
233 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
234 },
235 ],
236 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
237 },
238 ],
239 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
240 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
241 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
242 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
243 &quot;A String&quot;,
244 ],
245 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
246 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
247 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
248 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
249 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
250 },
251 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
252 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
253 {
254 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
255 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
256 },
257 ],
258 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
259 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
260 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
261 # Object with schema name: MessagePart
262 ],
263 },
264 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
265 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
266 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
267 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
268 }</pre>
269 </div>
270
271 <div class="method">
272 <code class="details" id="import_">import_(userId, body=None, deleted=None, internalDateSource=None, media_body=None, media_mime_type=None, neverMarkSpam=None, processForCalendar=None, x__xgafv=None)</code>
273 <pre>Imports a message into only this user&#x27;s mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. This method doesn&#x27;t perform SPF checks, so it might not work for some spam messages, such as those attempting to perform domain spoofing. This method does not send a message. Note that the maximum size of the message is 150 MB.
274
275 Args:
276 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
277 body: object, The request body.
278 The object takes the form of:
279
280 { # An email message.
281 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
282 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
283 &quot;fields&quot;: [ # Field values for the given classification label ID.
284 { # Field values for a classification label.
285 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
286 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
287 },
288 ],
289 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
290 },
291 ],
292 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
293 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
294 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
295 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
296 &quot;A String&quot;,
297 ],
298 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
299 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
300 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
301 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
302 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
303 },
304 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
305 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
306 {
307 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
308 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
309 },
310 ],
311 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
312 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
313 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
314 # Object with schema name: MessagePart
315 ],
316 },
317 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
318 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
319 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
320 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
321 }
322
323 deleted: boolean, Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for Google Workspace accounts.
324 internalDateSource: string, Source for Gmail&#x27;s internal date of the message.
325 Allowed values
326 receivedTime - Internal message date set to current time when received by Gmail.
327 dateHeader - Internal message time based on &#x27;Date&#x27; header in email, when valid.
328 media_body: string, The filename of the media request body, or an instance of a MediaUpload object.
329 media_mime_type: string, The MIME type of the media request body, or an instance of a MediaUpload object.
330 neverMarkSpam: boolean, Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox.
331 processForCalendar: boolean, Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user.
332 x__xgafv: string, V1 error format.
333 Allowed values
334 1 - v1 error format
335 2 - v2 error format
336
337 Returns:
338 An object of the form:
339
340 { # An email message.
341 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
342 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
343 &quot;fields&quot;: [ # Field values for the given classification label ID.
344 { # Field values for a classification label.
345 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
346 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
347 },
348 ],
349 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
350 },
351 ],
352 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
353 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
354 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
355 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
356 &quot;A String&quot;,
357 ],
358 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
359 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
360 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
361 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
362 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
363 },
364 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
365 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
366 {
367 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
368 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
369 },
370 ],
371 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
372 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
373 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
374 # Object with schema name: MessagePart
375 ],
376 },
377 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
378 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
379 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
380 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
381 }</pre>
382 </div>
383
384 <div class="method">
385 <code class="details" id="insert">insert(userId, body=None, deleted=None, internalDateSource=None, media_body=None, media_mime_type=None, x__xgafv=None)</code>
386 <pre>Directly inserts a message into only this user&#x27;s mailbox similar to `IMAP APPEND`, bypassing most scanning and classification. Does not send a message. For more information, see [Create and send email messages](https://developers.google.com/workspace/gmail/api/guides/sending).
387
388 Args:
389 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
390 body: object, The request body.
391 The object takes the form of:
392
393 { # An email message.
394 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
395 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
396 &quot;fields&quot;: [ # Field values for the given classification label ID.
397 { # Field values for a classification label.
398 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
399 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
400 },
401 ],
402 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
403 },
404 ],
405 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
406 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
407 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
408 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
409 &quot;A String&quot;,
410 ],
411 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
412 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
413 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
414 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
415 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
416 },
417 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
418 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
419 {
420 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
421 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
422 },
423 ],
424 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
425 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
426 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
427 # Object with schema name: MessagePart
428 ],
429 },
430 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
431 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
432 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
433 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
434 }
435
436 deleted: boolean, Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for Google Workspace accounts.
437 internalDateSource: string, Source for Gmail&#x27;s internal date of the message.
438 Allowed values
439 receivedTime - Internal message date set to current time when received by Gmail.
440 dateHeader - Internal message time based on &#x27;Date&#x27; header in email, when valid.
441 media_body: string, The filename of the media request body, or an instance of a MediaUpload object.
442 media_mime_type: string, The MIME type of the media request body, or an instance of a MediaUpload object.
443 x__xgafv: string, V1 error format.
444 Allowed values
445 1 - v1 error format
446 2 - v2 error format
447
448 Returns:
449 An object of the form:
450
451 { # An email message.
452 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
453 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
454 &quot;fields&quot;: [ # Field values for the given classification label ID.
455 { # Field values for a classification label.
456 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
457 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
458 },
459 ],
460 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
461 },
462 ],
463 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
464 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
465 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
466 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
467 &quot;A String&quot;,
468 ],
469 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
470 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
471 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
472 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
473 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
474 },
475 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
476 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
477 {
478 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
479 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
480 },
481 ],
482 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
483 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
484 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
485 # Object with schema name: MessagePart
486 ],
487 },
488 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
489 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
490 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
491 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
492 }</pre>
493 </div>
494
495 <div class="method">
496 <code class="details" id="list">list(userId, includeSpamTrash=None, labelIds=None, maxResults=None, pageToken=None, q=None, x__xgafv=None)</code>
497 <pre>Lists the messages in the user&#x27;s mailbox. For more information, see [List Gmail messages](https://developers.google.com/workspace/gmail/api/guides/list-messages).
498
499 Args:
500 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
501 includeSpamTrash: boolean, Include messages from `SPAM` and `TRASH` in the results.
502 labelIds: string, Only return messages with labels that match all of the specified label IDs. Messages in a thread might have labels that other messages in the same thread don&#x27;t have. To learn more, see [Manage labels on messages and threads](https://developers.google.com/workspace/gmail/api/guides/labels#manage_labels_on_messages_threads). (repeated)
503 maxResults: integer, Maximum number of messages to return. This field defaults to 100. The maximum allowed value for this field is 500.
504 pageToken: string, Page token to retrieve a specific page of results in the list.
505 q: string, Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, `&quot;from:[email protected] rfc822msgid: is:unread&quot;`. Parameter cannot be used when accessing the api using the gmail.metadata scope.
506 x__xgafv: string, V1 error format.
507 Allowed values
508 1 - v1 error format
509 2 - v2 error format
510
511 Returns:
512 An object of the form:
513
514 {
515 &quot;messages&quot;: [ # List of messages. Note that each message resource contains only an `id` and a `threadId`. Additional message details can be fetched using the messages.get method.
516 { # An email message.
517 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
518 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
519 &quot;fields&quot;: [ # Field values for the given classification label ID.
520 { # Field values for a classification label.
521 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
522 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
523 },
524 ],
525 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
526 },
527 ],
528 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
529 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
530 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
531 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
532 &quot;A String&quot;,
533 ],
534 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
535 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
536 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
537 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
538 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
539 },
540 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
541 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
542 {
543 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
544 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
545 },
546 ],
547 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
548 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
549 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
550 # Object with schema name: MessagePart
551 ],
552 },
553 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
554 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
555 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
556 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
557 },
558 ],
559 &quot;nextPageToken&quot;: &quot;A String&quot;, # Token to retrieve the next page of results in the list.
560 &quot;resultSizeEstimate&quot;: 42, # Estimated total number of results.
561 }</pre>
562 </div>
563
564 <div class="method">
565 <code class="details" id="list_next">list_next()</code>
566 <pre>Retrieves the next page of results.
567
568 Args:
569 previous_request: The request for the previous page. (required)
570 previous_response: The response from the request for the previous page. (required)
571
572 Returns:
573 A request object that you can call &#x27;execute()&#x27; on to request the next
574 page. Returns None if there are no more items in the collection.
575 </pre>
576 </div>
577
578 <div class="method">
579 <code class="details" id="modify">modify(userId, id, body=None, x__xgafv=None)</code>
580 <pre>Modifies the labels and the Classification Label values on the specified message. For administrators modifying message for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.modify.restricted` scope.
581
582 Args:
583 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
584 id: string, The ID of the message to modify. (required)
585 body: object, The request body.
586 The object takes the form of:
587
588 {
589 &quot;addClassificationLabels&quot;: [ # A list of classification label values to add. If a Classification Label with the same label ID is already applied to the message, fields with existing field IDs will be updated and fields with new field IDs will be added. There&#x27;s a limit of 20 Classification Label values per request. If the message is already classified and the final total number of Classification Label values exceeds the maximum allowed number of Classification Label values per message, the modification fails.
590 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
591 &quot;fields&quot;: [ # Field values for the given classification label ID.
592 { # Field values for a classification label.
593 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
594 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
595 },
596 ],
597 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
598 },
599 ],
600 &quot;addLabelIds&quot;: [ # A list of IDs of labels to add to this message. You can add up to 100 labels with each update.
601 &quot;A String&quot;,
602 ],
603 &quot;removeClassificationLabelIds&quot;: [ # A list of Classification Label values to remove from this message.
604 &quot;A String&quot;,
605 ],
606 &quot;removeLabelIds&quot;: [ # A list IDs of labels to remove from this message. You can remove up to 100 labels with each update.
607 &quot;A String&quot;,
608 ],
609 }
610
611 x__xgafv: string, V1 error format.
612 Allowed values
613 1 - v1 error format
614 2 - v2 error format
615
616 Returns:
617 An object of the form:
618
619 { # An email message.
620 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
621 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
622 &quot;fields&quot;: [ # Field values for the given classification label ID.
623 { # Field values for a classification label.
624 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
625 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
626 },
627 ],
628 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
629 },
630 ],
631 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
632 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
633 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
634 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
635 &quot;A String&quot;,
636 ],
637 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
638 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
639 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
640 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
641 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
642 },
643 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
644 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
645 {
646 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
647 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
648 },
649 ],
650 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
651 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
652 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
653 # Object with schema name: MessagePart
654 ],
655 },
656 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
657 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
658 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
659 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
660 }</pre>
661 </div>
662
663 <div class="method">
664 <code class="details" id="send">send(userId, body=None, media_body=None, media_mime_type=None, x__xgafv=None)</code>
665 <pre>Sends the specified message to the recipients in the `To`, `Cc`, and `Bcc` headers. For more information, see [Create and send email messages](https://developers.google.com/workspace/gmail/api/guides/sending).
666
667 Args:
668 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
669 body: object, The request body.
670 The object takes the form of:
671
672 { # An email message.
673 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
674 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
675 &quot;fields&quot;: [ # Field values for the given classification label ID.
676 { # Field values for a classification label.
677 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
678 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
679 },
680 ],
681 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
682 },
683 ],
684 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
685 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
686 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
687 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
688 &quot;A String&quot;,
689 ],
690 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
691 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
692 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
693 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
694 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
695 },
696 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
697 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
698 {
699 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
700 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
701 },
702 ],
703 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
704 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
705 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
706 # Object with schema name: MessagePart
707 ],
708 },
709 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
710 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
711 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
712 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
713 }
714
715 media_body: string, The filename of the media request body, or an instance of a MediaUpload object.
716 media_mime_type: string, The MIME type of the media request body, or an instance of a MediaUpload object.
717 x__xgafv: string, V1 error format.
718 Allowed values
719 1 - v1 error format
720 2 - v2 error format
721
722 Returns:
723 An object of the form:
724
725 { # An email message.
726 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
727 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
728 &quot;fields&quot;: [ # Field values for the given classification label ID.
729 { # Field values for a classification label.
730 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
731 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
732 },
733 ],
734 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
735 },
736 ],
737 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
738 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
739 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
740 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
741 &quot;A String&quot;,
742 ],
743 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
744 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
745 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
746 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
747 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
748 },
749 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
750 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
751 {
752 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
753 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
754 },
755 ],
756 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
757 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
758 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
759 # Object with schema name: MessagePart
760 ],
761 },
762 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
763 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
764 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
765 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
766 }</pre>
767 </div>
768
769 <div class="method">
770 <code class="details" id="trash">trash(userId, id, x__xgafv=None)</code>
771 <pre>Moves the specified message to the trash.
772
773 Args:
774 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
775 id: string, The ID of the message to Trash. (required)
776 x__xgafv: string, V1 error format.
777 Allowed values
778 1 - v1 error format
779 2 - v2 error format
780
781 Returns:
782 An object of the form:
783
784 { # An email message.
785 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
786 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
787 &quot;fields&quot;: [ # Field values for the given classification label ID.
788 { # Field values for a classification label.
789 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
790 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
791 },
792 ],
793 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
794 },
795 ],
796 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
797 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
798 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
799 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
800 &quot;A String&quot;,
801 ],
802 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
803 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
804 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
805 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
806 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
807 },
808 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
809 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
810 {
811 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
812 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
813 },
814 ],
815 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
816 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
817 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
818 # Object with schema name: MessagePart
819 ],
820 },
821 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
822 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
823 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
824 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
825 }</pre>
826 </div>
827
828 <div class="method">
829 <code class="details" id="untrash">untrash(userId, id, x__xgafv=None)</code>
830 <pre>Removes the specified message from the trash.
831
832 Args:
833 userId: string, The user&#x27;s email address. The special value `me` can be used to indicate the authenticated user. (required)
834 id: string, The ID of the message to remove from Trash. (required)
835 x__xgafv: string, V1 error format.
836 Allowed values
837 1 - v1 error format
838 2 - v2 error format
839
840 Returns:
841 An object of the form:
842
843 { # An email message.
844 &quot;classificationLabelValues&quot;: [ # Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There&#x27;s a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.
845 { # Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
846 &quot;fields&quot;: [ # Field values for the given classification label ID.
847 { # Field values for a classification label.
848 &quot;fieldId&quot;: &quot;A String&quot;, # Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
849 &quot;selection&quot;: &quot;A String&quot;, # Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
850 },
851 ],
852 &quot;labelId&quot;: &quot;A String&quot;, # Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
853 },
854 ],
855 &quot;historyId&quot;: &quot;A String&quot;, # The ID of the last history record that modified this message.
856 &quot;id&quot;: &quot;A String&quot;, # The immutable ID of the message.
857 &quot;internalDate&quot;: &quot;A String&quot;, # The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
858 &quot;labelIds&quot;: [ # List of IDs of labels applied to this message.
859 &quot;A String&quot;,
860 ],
861 &quot;payload&quot;: { # A single MIME message part. # The parsed email structure in the message parts.
862 &quot;body&quot;: { # The body of a single MIME message part. # The message part body for this part, which may be empty for container MIME message parts.
863 &quot;attachmentId&quot;: &quot;A String&quot;, # When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
864 &quot;data&quot;: &quot;A String&quot;, # The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
865 &quot;size&quot;: 42, # Number of bytes for the message part data (encoding notwithstanding).
866 },
867 &quot;filename&quot;: &quot;A String&quot;, # The filename of the attachment. Only present if this message part represents an attachment.
868 &quot;headers&quot;: [ # List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
869 {
870 &quot;name&quot;: &quot;A String&quot;, # The name of the header before the `:` separator. For example, `To`.
871 &quot;value&quot;: &quot;A String&quot;, # The value of the header after the `:` separator. For example, `[email protected]`.
872 },
873 ],
874 &quot;mimeType&quot;: &quot;A String&quot;, # The MIME type of the message part.
875 &quot;partId&quot;: &quot;A String&quot;, # The immutable ID of the message part.
876 &quot;parts&quot;: [ # The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
877 # Object with schema name: MessagePart
878 ],
879 },
880 &quot;raw&quot;: &quot;A String&quot;, # The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update
881 &quot;sizeEstimate&quot;: 42, # Estimated size in bytes of the message.
882 &quot;snippet&quot;: &quot;A String&quot;, # A short part of the message text.
883 &quot;threadId&quot;: &quot;A String&quot;, # The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
884 }</pre>
885 </div>
886
887 </body></html>