@pnp/cli-microsoft365 5.8.0-beta.b2e656e → 5.8.0-beta.f956c5d

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,15 +32,19 @@ 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
  alias() {
36
38
  return [commands_1.default.SENDMAIL];
37
39
  }
38
40
  commandAction(logger, args, cb) {
39
41
  const bodyContents = args.options.bodyContents;
42
+ const isAppOnlyAuth = Auth_1.Auth.isAppOnlyAuth(Auth_1.default.service.accessTokens[this.resource].accessToken);
43
+ if (isAppOnlyAuth === true && !args.options.sender) {
44
+ return cb(new Command_1.CommandError(`Specify a upn or user id in the 'sender' option when using app only authentication.`));
45
+ }
40
46
  const requestOptions = {
41
- url: `${this.resource}/v1.0/me/sendMail`,
47
+ url: `${this.resource}/v1.0/${args.options.sender ? 'users/' + encodeURIComponent(args.options.sender) : 'me'}/sendMail`,
42
48
  headers: {
43
49
  accept: 'application/json;odata.metadata=none',
44
50
  'content-type': 'application/json'
@@ -62,6 +68,13 @@ class OutlookMailSendCommand extends GraphCommand_1.default {
62
68
  saveToSentItems: args.options.saveToSentItems
63
69
  }
64
70
  };
71
+ if (args.options.mailbox) {
72
+ requestOptions.data.message.from = {
73
+ emailAddress: {
74
+ address: args.options.mailbox
75
+ }
76
+ };
77
+ }
65
78
  request_1.default
66
79
  .post(requestOptions)
67
80
  .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
@@ -72,7 +85,9 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
72
85
  Object.assign(this.telemetryProperties, {
73
86
  bodyContents: typeof args.options.bodyContents !== 'undefined',
74
87
  bodyContentType: args.options.bodyContentType,
75
- saveToSentItems: args.options.saveToSentItems
88
+ saveToSentItems: args.options.saveToSentItems,
89
+ mailbox: typeof args.options.mailbox !== 'undefined',
90
+ sender: typeof args.options.sender !== 'undefined'
76
91
  });
77
92
  });
78
93
  }, _OutlookMailSendCommand_initOptions = function _OutlookMailSendCommand_initOptions() {
@@ -80,6 +95,10 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
80
95
  option: '-s, --subject <subject>'
81
96
  }, {
82
97
  option: '-t, --to <to>'
98
+ }, {
99
+ option: '--sender [sender]'
100
+ }, {
101
+ option: '-m, --mailbox [mailbox]'
83
102
  }, {
84
103
  option: '--bodyContents <bodyContents>'
85
104
  }, {
@@ -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 sendmail
2
2
 
3
- Sends e-mail on behalf of the current user
3
+ Sends an e-mail
4
4
 
5
5
  ## Usage
6
6
 
@@ -22,6 +22,12 @@ m365 outlook sendmail [options]
22
22
  `-t, --to <to>`
23
23
  : Comma-separated list of e-mails to send the message to
24
24
 
25
+ `--sender [sender]`
26
+ : Optional upn or user id to specify what account to send the message from. Also see the remarks section.
27
+
28
+ `-m, --mailbox [mailbox]`
29
+ : 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.
30
+
25
31
  `--bodyContents <bodyContents>`
26
32
  : String containing the body of the e-mail to send
27
33
 
@@ -33,6 +39,25 @@ m365 outlook sendmail [options]
33
39
 
34
40
  --8<-- "docs/cmd/_global.md"
35
41
 
42
+ ## Remarks
43
+
44
+ ### If you are connected using app only authentication
45
+
46
+ - 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.
47
+ - 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.
48
+
49
+ !!! important
50
+ You need `Mail.Send` application permissions on the Microsoft Graph to be able to send mails using an application identity.
51
+
52
+ ### If you are connected with a regular user account
53
+
54
+ - 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.
55
+ - You can specify the `--sender` option if you want to send an email as if you were the other user.
56
+ 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.
57
+
58
+ !!! important
59
+ 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.
60
+
36
61
  ## Examples
37
62
 
38
63
  Send a text e-mail to the specified e-mail address
@@ -58,3 +83,21 @@ Send a text e-mail to the specified e-mail address. Don't store the e-mail in se
58
83
  ```sh
59
84
  m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --saveToSentItems false
60
85
  ```
86
+
87
+ Send an email on behalf of a shared mailbox using the signed in 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" --mailbox sales@contoso.com
91
+ ```
92
+
93
+ Send an email as another user
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
97
+ ```
98
+
99
+ Send an email as another user, on behalf of a shared mailbox
100
+
101
+ ```sh
102
+ 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
103
+ ```
@@ -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": "5.8.0-beta.b2e656e",
3
+ "version": "5.8.0-beta.f956c5d",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",