Skip to content

Enhancement: Add ability to send emails from a specified account or inbox #3589

@martinlingstuyl

Description

@martinlingstuyl

The command m365 outlook mail send does not support app only permissions. It can only be used in delegated mode.
It can also not be used to send mail from a shared mailbox.

This issue is about adding extra options to overcome these limitations.

Option Description
--sender [sender] The upn or user id of the account that sends the email. Defaults to the signed in user.
-m, --mailbox [mailbox] An optional e-mailaddress that the sender uses to send the email. For example a shared mailbox, group or distribution list. The sender needs to be a delegate on this mailbox.

Remarks

If you are connected using app only authentication:

  • Specify a user id or UPN in the --sender option. You need Mail.Send application permissions on the Microsoft Graph to be able to do this. The email will be sent as if it came from the specified user, and can optionally be saved in the sent folder of that user account.
  • You can optionally also specify the --mailbox option to send mail on behalf of a shared mailbox, group or distribution list.

If you are connected with a regular user account:

  • Specify the --mailbox option if you want to send an email on behalf of another mailbox. This can be a shared mailbox, group or distribution list. It will be visible in the email that the email was sent by the signed in user, on behalf of the specified mailbox. You need to be assigned delegate permissions on the mailbox to be able to do this.
  • You can specify the --sender option if you have full control permissions on the mailbox of another user. The email will be sent as if it came from the specified user, and can optionally be saved in the sent folder of that user account.

Examples

Send an email on behalf of a shared mailbox using the signed in user

m365 outlook mail send --to [email protected] --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --mailbox [email protected]

Send an email as another user

m365 outlook mail send --to [email protected] --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --sender [email protected]

Additional Info

Instead of the /me endpoint, we'd need the following: /users/{id | userPrincipalName}/sendMail when using the --sender option.

More info:
https://docs.microsoft.com/en-us/graph/api/user-sendmail
https://docs.microsoft.com/en-us/graph/outlook-send-mail-from-other-user

When using app only authentication, the command should throw an error if the --sender is not specified.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions