# Users - Gmail - Delegates - [Notes](#notes) - [API documentation](#api-documentation) - [Definitions](#definitions) - [Aliases](#aliases) - [Delegator Banner](#delegator-banner) - [Delegate Notification](#delegate-notification) - [Create Gmail delegates](#create-gmail-delegates) - [Delete Gmail delegates](#delete-gmail-delegates) - [Update Gmail delegates](#update-gmail-delegates) - [Display Gmail delegates](#display-gmail-delegates) - [Delete all delegates for a user](#delete-all-delegates-for-a-user) ## Notes To use Gmail delegation, the delegator and delagatee must be in org units where mail delegation is enabled. In the admin console, go to Apps/Google Workspace/Gmail/User Settings. ## API documentation * [Gmail API - Delegates](https://developers.google.com/gmail/api/v1/reference/users.settings.delegates) * [Delegation Notes](https://support.google.com/a/answer/7223765) * [Delegation Notes](https://support.google.com/a/answer/11946994) ## Definitions * [``](Collections-of-Users) ``` ::= (.)+ ::= @ ::= id: ::= || ::= "(,)*" ::= | | | See: https://github.com/GAM-team/GAM/wiki/Collections-of-Users ::= ::= ::= https://storage.cloud.google.com//| https://storage.googleapis.com//| gs:///| / ::= ||( ) ::= (message|textmessage|htmlmessage )| (file|textfile|htmlfile [charset ])| (gdoc|ghtml )| (gcsdoc|gcshtml ) ``` ## Aliases It is an error to use a user's alias as a delegate; if you try, an error will be generated. The `convertalias` option causes GAM to make an extra API call per user in `` to convert aliases to primary email addresses. If you know that all of the email addresses in `` are primary, you can omit `convertalias` and avoid the extra API calls. ## Delegator Banner When creating a delegate, the following banner is displayed in the delegator's Gmail inbox, it can not be suppressed. ``` now has delegated access to your account. This notice will end in 7 days. ``` ## Delegate Notification When creating a delegate, you can send a message to the delegate. ``` [notify [] [subject ] [from ] [mailbox ] [replyto ] [] [html []] ] ``` * `notify []` - Should notification be sent In the subject and message, these strings will be replaced with the specified values: * `#user#` - user's email address * `#delegate#` - delegate's email address If subject is not specified, the following value will be used: * `#user# mail delegation to #delegate#` `` is the message, there are four ways to specify it: * `message|textmessage|htmlmessage ` - Use `` as the message * `file|htmlfile [charset ]` - Read the message from `` * `gdoc|ghtml ` - Read the message from `` * `gcsdoc|gcshtml ` - Read the message from the Google Cloud Storage file `` If ``is not specified, the following value will be used: * `#user# has granted you #delegate# access to read, delete and send mail on their behalf.` Unless specified in ``, messages are sent as plain text, use `html` or `html true` to indicate that the message is HTML. Use `\n` in `message ` to indicate a line break; no other special characters are recognized. By default, the email is sent from the admin user identified in oauth2.txt, `gam oauth info` will show the value. Use `from ` to specify an alternate from address. Use `mailbox ` if `from ` specifies a group; GAM has to login as a user to be able to send a message. Gam gets no indication as to the status of the message delivery; the from user will get a non-delivery receipt if the message could not be sent to the delegate. ## Create Gmail delegates These two commands are equivalent. ``` gam add delegate|delegates [convertalias] [[notify ] [subject ] [from ] [mailbox ] [replyto ] [] ] gam delegate|delegates to [convertalias] [[notify ] [subject ] [from ] [mailbox ] [replyto ] [] ] ``` ### Example To give Bob access to Fred's mailbox as a delegate: ``` gam user fred@domain.com add delegate bob@domain.com gam user fred@domain.com delegate to bob@domain.com ``` ## Delete Gmail delegates ``` gam delete|del delegate|delegates [convertalias] ``` ## Update Gmail delegates Update delegates to be able to access a user's contacts. ``` gam update delegate|delegates [convertalias] [] ``` If `` is omitted, all of a user's accepted delegates are updated. ## Display Gmail delegates ``` gam show delegates|delegate [shownames] [csv] gam print delegates|delegate [todrive *] [shownames] ``` By default, delegate names are not displayed; use the `shownames` option to display the delegates name. This involves an extra API call per delegate email address. By default, `show delegates` displays indented keys and values; use the `csv` option to have just the values shown as a comma separated list. ## Delete all delegates for a user ``` $ gam redirect csv ./Delegates.csv user testsimple print delegates Getting all Delegates for testsimple@domain.com $ gam redirect stdout - multiprocess csv Delegates.csv gam user "~User" delete delegate "~delegateAddress" 2023-11-10T06:56:04.118-08:00,0/3,Using 3 processes... 2023-11-10T06:56:04.123-08:00,0,Processing item 3/3 User: testsimple@domain.com, Delete 1 Delegate User: testsimple@domain.com, Delegate: testuser1@domain.com, Deleted User: testsimple@domain.com, Delete 1 Delegate User: testsimple@domain.com, Delegate: testuser2@domain.com, Deleted User: testsimple@domain.com, Delete 1 Delegate User: testsimple@domain.com, Delegate: testgroup@domain.com, Deleted 2023-11-10T06:56:07.253-08:00,0/3,Processing complete ```