Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/28 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/28 (UTC)."],[[["\u003cp\u003eComposeActionResponseBuilder helps create responses for actions that generate draft emails when a UI element is interacted with.\u003c/p\u003e\n"],["\u003cp\u003eIt's important to understand that this is distinct from compose actions used to extend the Gmail compose UI.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use this builder to set a Gmail draft created using methods like GmailMessage.createDraftReply().\u003c/p\u003e\n"],["\u003cp\u003eThe build() method finalizes the response and ensures it's valid before use.\u003c/p\u003e\n"]]],["The `ComposeActionResponseBuilder` creates responses to actions that compose draft messages. It has two key methods: `build()` and `setGmailDraft(draft)`. `build()` constructs and validates the `ComposeActionResponse`. If it is invalid an error is thrown. `setGmailDraft(draft)` sets the `GmailDraft` using functions such as `GmailMessage.createDraftReply(body)`, allowing for modification of the draft before composing. The builder itself is not directly related to compose actions but creates responses when UI elements are selected.\n"],null,["ComposeActionResponseBuilder\n\nA builder for [ComposeActionResponse](/apps-script/reference/card-service/compose-action-response) objects.\n\n\n| **Note** : This object isn't related to **compose actions** that are used to [extend the compose UI](/gmail/add-ons/how-tos/extending-compose-ui). Rather, this builder creates responses to an [Action](/apps-script/reference/card-service/action) that composes draft messages when a specific UI element is selected.\n\n\u003cbr /\u003e\n\nMethods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [build()](#build()) | [ComposeActionResponse](/apps-script/reference/card-service/compose-action-response) | Builds the current compose action response and validates it. |\n| [setGmailDraft(draft)](#setGmailDraft(GmailDraft)) | [ComposeActionResponseBuilder](#) | Sets the draft [GmailMessage](../gmail/gmail-message.html) created using [GmailMessage.createDraftReply(body)](../gmail/gmail-message.html#createDraftReply(String)) or similar functions. |\n\nDetailed documentation \n\n`build()` \nBuilds the current compose action response and validates it.\n\nReturn\n\n\n[ComposeActionResponse](/apps-script/reference/card-service/compose-action-response) --- A validated [ComposeActionResponse](/apps-script/reference/card-service/compose-action-response).\n\nThrows\n\n\n[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the constructed compose action response isn't valid.\n\n*** ** * ** ***\n\n`set``Gmail``Draft(draft)` \nSets the draft [GmailMessage](../gmail/gmail-message.html) created\nusing [GmailMessage.createDraftReply(body)](../gmail/gmail-message.html#createDraftReply(String)) or\nsimilar functions.\n\nParameters\n\n| Name | Type | Description |\n|---------|-----------------------------------------|-----------------------------------------------------|\n| `draft` | [GmailDraft](../gmail/gmail-draft.html) | The [GmailDraft](../gmail/gmail-draft.html) to use. |\n\nReturn\n\n\n[ComposeActionResponseBuilder](#) --- This object, for chaining."]]