@pnp/cli-microsoft365 6.0.0-beta.de4f962 → 6.0.0-beta.dee678a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _OutlookMailSendCommand_instances, _OutlookMailSendCommand_initTelemetry, _OutlookMailSendCommand_initOptions, _OutlookMailSendCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Auth_1 = require("../../../../Auth");
19
+ const Command_1 = require("../../../../Command");
18
20
  const request_1 = require("../../../../request");
19
21
  const GraphCommand_1 = require("../../../base/GraphCommand");
20
22
  const commands_1 = require("../../commands");
@@ -30,12 +32,16 @@ class OutlookMailSendCommand extends GraphCommand_1.default {
30
32
  return commands_1.default.MAIL_SEND;
31
33
  }
32
34
  get description() {
33
- return 'Sends e-mail on behalf of the current user';
35
+ return 'Sends an e-mail';
34
36
  }
35
37
  commandAction(logger, args, cb) {
36
38
  const bodyContents = args.options.bodyContents;
39
+ const isAppOnlyAuth = Auth_1.Auth.isAppOnlyAuth(Auth_1.default.service.accessTokens[this.resource].accessToken);
40
+ if (isAppOnlyAuth === true && !args.options.sender) {
41
+ return cb(new Command_1.CommandError(`Specify a upn or user id in the 'sender' option when using app only authentication.`));
42
+ }
37
43
  const requestOptions = {
38
- url: `${this.resource}/v1.0/me/sendMail`,
44
+ url: `${this.resource}/v1.0/${args.options.sender ? 'users/' + encodeURIComponent(args.options.sender) : 'me'}/sendMail`,
39
45
  headers: {
40
46
  accept: 'application/json;odata.metadata=none',
41
47
  'content-type': 'application/json'
@@ -59,6 +65,13 @@ class OutlookMailSendCommand extends GraphCommand_1.default {
59
65
  saveToSentItems: args.options.saveToSentItems
60
66
  }
61
67
  };
68
+ if (args.options.mailbox) {
69
+ requestOptions.data.message.from = {
70
+ emailAddress: {
71
+ address: args.options.mailbox
72
+ }
73
+ };
74
+ }
62
75
  request_1.default
63
76
  .post(requestOptions)
64
77
  .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
@@ -69,7 +82,9 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
69
82
  Object.assign(this.telemetryProperties, {
70
83
  bodyContents: typeof args.options.bodyContents !== 'undefined',
71
84
  bodyContentType: args.options.bodyContentType,
72
- saveToSentItems: args.options.saveToSentItems
85
+ saveToSentItems: args.options.saveToSentItems,
86
+ mailbox: typeof args.options.mailbox !== 'undefined',
87
+ sender: typeof args.options.sender !== 'undefined'
73
88
  });
74
89
  });
75
90
  }, _OutlookMailSendCommand_initOptions = function _OutlookMailSendCommand_initOptions() {
@@ -77,6 +92,10 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
77
92
  option: '-s, --subject <subject>'
78
93
  }, {
79
94
  option: '-t, --to <to>'
95
+ }, {
96
+ option: '--sender [sender]'
97
+ }, {
98
+ option: '-m, --mailbox [mailbox]'
80
99
  }, {
81
100
  option: '--bodyContents <bodyContents>'
82
101
  }, {
@@ -64,7 +64,7 @@ _PpEnvironmentListCommand_instances = new WeakSet(), _PpEnvironmentListCommand_i
64
64
  });
65
65
  }, _PpEnvironmentListCommand_initOptions = function _PpEnvironmentListCommand_initOptions() {
66
66
  this.options.unshift({
67
- option: '-a, --asAdmin [teamId]'
67
+ option: '-a, --asAdmin'
68
68
  });
69
69
  };
70
70
  module.exports = new PpEnvironmentListCommand();
@@ -42,12 +42,10 @@ const addFileCommands = {
42
42
  addFileCommand: 'cat > [FILEPATH] << EOF [FILECONTENT]EOF'
43
43
  },
44
44
  powershell: {
45
- addFileCommand: `@"[FILECONTENT]"@ | Out-File -FilePath "[FILEPATH]"
46
- `
45
+ addFileCommand: `@"[FILECONTENT]"@ | Out-File -FilePath [FILEPATH]`
47
46
  },
48
47
  cmd: {
49
- addFileCommand: `echo [FILECONTENT] > "[FILEPATH]"
50
- `
48
+ addFileCommand: `echo [FILECONTENT] > [FILEPATH]`
51
49
  }
52
50
  };
53
51
  const removeFileCommands = {
package/dist/utils/md.js CHANGED
@@ -46,7 +46,7 @@ function convertHyperlinks(md) {
46
46
  });
47
47
  }
48
48
  function convertCodeFences(md) {
49
- const regex = new RegExp('^```.*?' + os_1.EOL + '(.*?)```' + os_1.EOL, 'gms');
49
+ const regex = new RegExp('^```.*?(?:\r\n|\n)(.*?)```(?:\r\n|\n)', 'gms');
50
50
  return md.replace(regex, (match, code) => {
51
51
  return ` ${code}${os_1.EOL}`;
52
52
  });
@@ -1,6 +1,6 @@
1
1
  # outlook mail send
2
2
 
3
- Sends e-mail on behalf of the current user
3
+ Sends an e-mail
4
4
 
5
5
  ## Usage
6
6
 
@@ -16,6 +16,12 @@ m365 outlook mail send [options]
16
16
  `-t, --to <to>`
17
17
  : Comma-separated list of e-mails to send the message to
18
18
 
19
+ `--sender [sender]`
20
+ : Optional upn or user id to specify what account to send the message from. Also see the remarks section.
21
+
22
+ `-m, --mailbox [mailbox]`
23
+ : Specify this option to send the email on behalf of another mailbox, for example a shared mailbox, group or distribution list. The sender needs to be a delegate on the specified mailbox. Also see the remarks section.
24
+
19
25
  `--bodyContents <bodyContents>`
20
26
  : String containing the body of the e-mail to send
21
27
 
@@ -27,6 +33,25 @@ m365 outlook mail send [options]
27
33
 
28
34
  --8<-- "docs/cmd/_global.md"
29
35
 
36
+ ## Remarks
37
+
38
+ ### If you are connected using app only authentication
39
+
40
+ - Always specify a user id or upn in the `--sender` option. 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.
41
+ - You can optionally also specify the `--mailbox` option to send mail on behalf of a shared mailbox, group or distribution list. The account used in the `--sender` option, needs to have 'Send on behalf of' permissions on the mailbox in question.
42
+
43
+ !!! important
44
+ You need `Mail.Send` application permissions on the Microsoft Graph to be able to send mails using an application identity.
45
+
46
+ ### If you are connected with a regular user account
47
+
48
+ - 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 you. You need to be assigned `Send on behalf of` permissions on the mailbox in question.
49
+ - You can specify the `--sender` option if you want to send an email as if you were the other user.
50
+ The sent email can optionally be saved in the sent folder of that user account. You'll need `Read and manage (Full Access)` permissions on the mailbox of the other user. You can combine the `--sender` and `--mailbox` options to let the other user send a mail on behalf of the specified mailbox.
51
+
52
+ !!! important
53
+ You need at least `Mail.Send` delegated permissions on the Microsoft Graph to be able to send emails. When specifying another user as sender, you'll need `Mail.Send.Shared` permissions.
54
+
30
55
  ## Examples
31
56
 
32
57
  Send a text e-mail to the specified e-mail address
@@ -52,3 +77,21 @@ Send a text e-mail to the specified e-mail address. Don't store the e-mail in se
52
77
  ```sh
53
78
  m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --saveToSentItems false
54
79
  ```
80
+
81
+ Send an email on behalf of a shared mailbox using the signed in user
82
+
83
+ ```sh
84
+ m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --mailbox sales@contoso.com
85
+ ```
86
+
87
+ Send an email as another user
88
+
89
+ ```sh
90
+ m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --sender svc_project@contoso.com
91
+ ```
92
+
93
+ Send an email as another user, on behalf of a shared mailbox
94
+
95
+ ```sh
96
+ m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --sender svc_project@contoso.com --mailbox sales@contoso.com
97
+ ```
@@ -10,7 +10,7 @@ m365 pp environment list [options]
10
10
 
11
11
  ## Options
12
12
 
13
- `-a, --asAdmin [teamId]`
13
+ `-a, --asAdmin`
14
14
  Run the command as admin and retrieve all environments. Lists only environments you have explicitly are assigned permissions to by default.
15
15
 
16
16
  --8<-- "docs/cmd/_global.md"
@@ -26,10 +26,10 @@ m365 spo list roleassignment add [options]
26
26
  : SharePoint ID of principal it may be either user id or group id we want to add permissions to. Specify principalId only when upn or groupName are not used.
27
27
 
28
28
  `--upn [upn]`
29
- : Upn/email of user to assign role to. Specify either upn or princpialId
29
+ : Upn/email of user to assign role to. Specify either upn or principalId
30
30
 
31
31
  `--groupName [groupName]`
32
- : Enter group name of Azure AD or SharePoint group.. Specify either groupName or princpialId
32
+ : Enter group name of Azure AD or SharePoint group.. Specify either groupName or principalId
33
33
 
34
34
  `--roleDefinitionId [roleDefinitionId]`
35
35
  : ID of role definition. Specify either roleDefinitionId or roleDefinitionName but not both
@@ -26,10 +26,10 @@ m365 spo list roleassignment remove [options]
26
26
  : SharePoint ID of principal it may be either user id or group id we want to remove permissions Specify principalId only when upn or groupName are not used.
27
27
 
28
28
  `--upn [upn]`
29
- : upn/email of user. Specify either upn or princpialId.
29
+ : upn/email of user. Specify either upn or principalId.
30
30
 
31
31
  `--groupName [groupName]`
32
- : enter group name of Azure AD or SharePoint group. Specify either groupName or princpialId.
32
+ : enter group name of Azure AD or SharePoint group. Specify either groupName or principalId.
33
33
 
34
34
  `--confirm`
35
35
  : Don't prompt for confirming removing the role assignment
@@ -29,10 +29,10 @@ m365 spo listitem roleassignment remove [options]
29
29
  : SharePoint ID of principal it may be either user id or group id we want to remove permissions Specify principalId only when upn or groupName are not used.
30
30
 
31
31
  `--upn [upn]`
32
- : upn/email of user. Specify either upn or princpialId.
32
+ : upn/email of user. Specify either upn or principalId.
33
33
 
34
34
  `--groupName [groupName]`
35
- : enter group name of Azure AD or SharePoint group. Specify either groupName or princpialId.
35
+ : enter group name of Azure AD or SharePoint group. Specify either groupName or principalId.
36
36
 
37
37
  `--confirm`
38
38
  : Don't prompt for confirming removing the role assignment
@@ -17,10 +17,10 @@ m365 spo web roleassignment add [options]
17
17
  : SharePoint ID of principal it may be either user id or group id we want to add permissions to. Specify principalId only when upn or groupName are not used.
18
18
 
19
19
  `--upn [upn]`
20
- : upn/email of user to assign role to. Specify either upn or princpialId
20
+ : upn/email of user to assign role to. Specify either upn or principalId
21
21
 
22
22
  `--groupName [groupName]`
23
- : enter group name of Azure AD or SharePoint group.. Specify either groupName or princpialId
23
+ : enter group name of Azure AD or SharePoint group.. Specify either groupName or principalId
24
24
 
25
25
  `--roleDefinitionId [roleDefinitionId]`
26
26
  : ID of role definition. Specify either roleDefinitionId or roleDefinitionName but not both
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "6.0.0-beta.de4f962",
3
+ "version": "6.0.0-beta.dee678a",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",