Skip to content

Commit 3cb5808

Browse files
author
github-actions
committed
Merge branch 'main' into prod
2 parents a366f81 + 9e1d205 commit 3cb5808

File tree

8 files changed

+220
-15
lines changed

8 files changed

+220
-15
lines changed

playlists-prod/outlook.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,15 @@
793793
group: Other Item APIs
794794
api_set:
795795
Mailbox: '1.15'
796+
- id: outlook-other-item-apis-get-loaded-message-properties
797+
name: 'Get properties of a loaded message (Message Compose, Message Read)'
798+
fileName: get-loaded-message-properties.yaml
799+
description: Gets the properties of the currently loaded message.
800+
rawUrl: >-
801+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml
802+
group: Other Item APIs
803+
api_set:
804+
Mailbox: '1.15'
796805
- id: outlook-get-set-isalldayevent
797806
name: Get and set the isAllDayEvent property (Appointment Organizer)
798807
fileName: get-set-isalldayevent.yaml

playlists/outlook.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,15 @@
793793
group: Other Item APIs
794794
api_set:
795795
Mailbox: '1.15'
796+
- id: outlook-other-item-apis-get-loaded-message-properties
797+
name: 'Get properties of a loaded message (Message Compose, Message Read)'
798+
fileName: get-loaded-message-properties.yaml
799+
description: Gets the properties of the currently loaded message.
800+
rawUrl: >-
801+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml
802+
group: Other Item APIs
803+
api_set:
804+
Mailbox: '1.15'
796805
- id: outlook-get-set-isalldayevent
797806
name: Get and set the isAllDayEvent property (Appointment Organizer)
798807
fileName: get-set-isalldayevent.yaml

samples/outlook/35-notifications/add-getall-remove.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ script:
3333
{
3434
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
3535
message: "Non-persistent informational notification message with id = " + id,
36-
icon: "icon1",
36+
icon: "PG.Icon.16",
3737
persistent: false
3838
};
3939
Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult);
@@ -46,7 +46,7 @@ script:
4646
{
4747
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
4848
message: "Persistent informational notification message with id = " + id,
49-
icon: "icon1",
49+
icon: "PG.Icon.16",
5050
persistent: true
5151
};
5252
Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult);
@@ -60,7 +60,7 @@ script:
6060
const details = {
6161
type: Office.MailboxEnums.ItemNotificationMessageType.InsightMessage,
6262
message: "This is an insight notification with id = " + id,
63-
icon: "icon1",
63+
icon: "PG.Icon.16",
6464
actions: [
6565
{
6666
actionText: "Open insight",
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
order: 31
2+
id: outlook-other-item-apis-get-loaded-message-properties
3+
name: 'Get properties of a loaded message (Message Compose, Message Read)'
4+
description: Gets the properties of the currently loaded message.
5+
host: OUTLOOK
6+
api_set:
7+
Mailbox: '1.15'
8+
script:
9+
content: |
10+
let list;
11+
12+
Office.onReady((info) => {
13+
if (info.host === Office.HostType.Outlook) {
14+
list = document.getElementById("selected-items");
15+
16+
// Register an event handler to identify when messages are selected.
17+
Office.context.mailbox.addHandlerAsync(Office.EventType.SelectedItemsChanged, run, (asyncResult) => {
18+
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
19+
console.log(asyncResult.error.message);
20+
return;
21+
}
22+
23+
console.log("Event handler added.");
24+
});
25+
26+
run();
27+
}
28+
});
29+
30+
function run() {
31+
// Clear the list of previously selected messages, if any.
32+
clearList(list);
33+
34+
// Get the subject line and sender's email address of each selected message and log them to a list in the task pane.
35+
Office.context.mailbox.getSelectedItemsAsync((asyncResult) => {
36+
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
37+
console.log(asyncResult.error.message);
38+
return;
39+
}
40+
41+
const selectedItems = asyncResult.value;
42+
43+
getItemInfo(selectedItems);
44+
});
45+
}
46+
47+
// Gets the subject line and sender's email address of each selected message.
48+
async function getItemInfo(selectedItems) {
49+
for (const item of selectedItems) {
50+
addToList(item.subject);
51+
await getSenderEmailAddress(item);
52+
}
53+
}
54+
55+
// Gets the sender's email address of each selected message.
56+
async function getSenderEmailAddress(item) {
57+
const itemId = item.itemId;
58+
await new Promise((resolve) => {
59+
Office.context.mailbox.loadItemByIdAsync(itemId, (result) => {
60+
if (result.status === Office.AsyncResultStatus.Failed) {
61+
console.log(result.error.message);
62+
return;
63+
}
64+
65+
const loadedItem = result.value;
66+
const sender = loadedItem.from.emailAddress;
67+
appendToListItem(sender);
68+
69+
// Unload the current message before processing another selected message.
70+
loadedItem.unloadAsync((asyncResult) => {
71+
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
72+
console.log(asyncResult.error.message);
73+
return;
74+
}
75+
76+
resolve();
77+
});
78+
});
79+
});
80+
}
81+
82+
// Clears the list in the task pane.
83+
function clearList(list) {
84+
while (list.firstChild) {
85+
list.removeChild(list.firstChild);
86+
}
87+
}
88+
89+
// Adds an item to a list in the task pane.
90+
function addToList(item) {
91+
const listItem = document.createElement("li");
92+
listItem.textContent = item;
93+
list.appendChild(listItem);
94+
}
95+
96+
// Appends data to the last item of the list in the task pane.
97+
function appendToListItem(data) {
98+
const listItem = list.lastChild;
99+
listItem.textContent += ` (${data})`;
100+
}
101+
language: typescript
102+
template:
103+
content: |-
104+
<section class="ms-Fabric ms-font-m">
105+
<p>This sample shows how to get the properties of the currently loaded message.</p>
106+
<p><b>Required mode</b>: Message Compose, Message Read</p>
107+
</section>
108+
<section class="ms-Fabric samples ms-font-m">
109+
<h3>Try it out</h3>
110+
<ol>
111+
<li>
112+
<p>Turn on the Reading Pane in Outlook. For guidance, see <a
113+
href="https://support.microsoft.com/office/2fd687ed-7fc4-4ae3-8eab-9f9b8c6d53f0" target="_blank">Use
114+
and configure the Reading Pane to preview messages</a>.</p>
115+
</li>
116+
<li>
117+
<p>Select a message from your mailbox. To select multiple messages, hold <kbd>Ctrl</kbd> (Windows) while
118+
selecting each message. You can select a maximum of 100 messages at a time.</p>
119+
</li>
120+
</ol>
121+
<p>The subject and email address of the sender are automatically logged to the "Selected messages" section of the
122+
task pane.</p>
123+
<p>To learn more about the item multi-select feature, see <a
124+
href="https://learn.microsoft.com/office/dev/add-ins/outlook/item-multi-select" target="_blank">Activate
125+
your Outlook add-in on multiple messages</a>.</p>
126+
<h3>Selected messages</h3>
127+
<ul id="selected-items"></ul>
128+
</section>
129+
language: html
130+
style:
131+
content: |-
132+
section.samples {
133+
margin-top: 20px;
134+
}
135+
136+
section.samples .ms-Button, section.setup .ms-Button {
137+
display: block;
138+
margin-bottom: 5px;
139+
margin-left: 20px;
140+
min-width: 80px;
141+
}
142+
language: css
143+
libraries: |
144+
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
145+
@types/office-js
146+
147+
office-ui-fabric-core@11.1.0/dist/css/fabric.min.css
148+
office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css
149+
150+
core-js@2.4.1/client/core.min.js
151+
@types/core-js
152+
153+
jquery@3.1.1
154+
@types/jquery@3.3.1
91 Bytes
Binary file not shown.

snippet-extractor-output/snippets.yaml

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8639,7 +8639,7 @@
86398639
{
86408640
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
86418641
message: "Non-persistent informational notification message with id = " + id,
8642-
icon: "icon1",
8642+
icon: "PG.Icon.16",
86438643
persistent: false
86448644
};
86458645
Office.context.mailbox.item.notificationMessages.addAsync(id, details,
@@ -8657,7 +8657,7 @@
86578657
{
86588658
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
86598659
message: "Persistent informational notification message with id = " + id,
8660-
icon: "icon1",
8660+
icon: "PG.Icon.16",
86618661
persistent: true
86628662
};
86638663
Office.context.mailbox.item.notificationMessages.addAsync(id, details,
@@ -9588,7 +9588,7 @@
95889588
{
95899589
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
95909590
message: "Non-persistent informational notification message with id = " + id,
9591-
icon: "icon1",
9591+
icon: "PG.Icon.16",
95929592
persistent: false
95939593
};
95949594
Office.context.mailbox.item.notificationMessages.addAsync(id, details,
@@ -9606,7 +9606,7 @@
96069606
{
96079607
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
96089608
message: "Persistent informational notification message with id = " + id,
9609-
icon: "icon1",
9609+
icon: "PG.Icon.16",
96109610
persistent: true
96119611
};
96129612
Office.context.mailbox.item.notificationMessages.addAsync(id, details,
@@ -10934,6 +10934,37 @@
1093410934

1093510935
console.log(result.value);
1093610936
});
10937+
'Office.Mailbox#loadItemByIdAsync:member(1)':
10938+
- >-
10939+
// Link to full sample:
10940+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml
10941+
10942+
10943+
async function getSenderEmailAddress(item) {
10944+
const itemId = item.itemId;
10945+
await new Promise((resolve) => {
10946+
Office.context.mailbox.loadItemByIdAsync(itemId, (result) => {
10947+
if (result.status === Office.AsyncResultStatus.Failed) {
10948+
console.log(result.error.message);
10949+
return;
10950+
}
10951+
10952+
const loadedItem = result.value;
10953+
const sender = loadedItem.from.emailAddress;
10954+
appendToListItem(sender);
10955+
10956+
// Unload the current message before processing another selected message.
10957+
loadedItem.unloadAsync((asyncResult) => {
10958+
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
10959+
console.log(asyncResult.error.message);
10960+
return;
10961+
}
10962+
10963+
resolve();
10964+
});
10965+
});
10966+
});
10967+
}
1093710968
'Office.Mailbox#makeEwsRequestAsync:member(1)':
1093810969
- >-
1093910970
// Link to full sample:
@@ -11070,7 +11101,7 @@
1107011101
const details = {
1107111102
type: Office.MailboxEnums.ItemNotificationMessageType.InsightMessage,
1107211103
message: "This is an insight notification with id = " + id,
11073-
icon: "icon1",
11104+
icon: "PG.Icon.16",
1107411105
actions: [
1107511106
{
1107611107
actionText: "Open insight",
@@ -12389,7 +12420,7 @@
1238912420
{
1239012421
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
1239112422
message: "Non-persistent informational notification message with id = " + id,
12392-
icon: "icon1",
12423+
icon: "PG.Icon.16",
1239312424
persistent: false
1239412425
};
1239512426
Office.context.mailbox.item.notificationMessages.addAsync(id, details,
@@ -12407,7 +12438,7 @@
1240712438
{
1240812439
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
1240912440
message: "Persistent informational notification message with id = " + id,
12410-
icon: "icon1",
12441+
icon: "PG.Icon.16",
1241112442
persistent: true
1241212443
};
1241312444
Office.context.mailbox.item.notificationMessages.addAsync(id, details,
@@ -13236,7 +13267,7 @@
1323613267
{
1323713268
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
1323813269
message: "Non-persistent informational notification message with id = " + id,
13239-
icon: "icon1",
13270+
icon: "PG.Icon.16",
1324013271
persistent: false
1324113272
};
1324213273
Office.context.mailbox.item.notificationMessages.addAsync(id, details,
@@ -13254,7 +13285,7 @@
1325413285
{
1325513286
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
1325613287
message: "Persistent informational notification message with id = " + id,
13257-
icon: "icon1",
13288+
icon: "PG.Icon.16",
1325813289
persistent: true
1325913290
};
1326013291
Office.context.mailbox.item.notificationMessages.addAsync(id, details,
@@ -13432,7 +13463,7 @@
1343213463
const details = {
1343313464
type: Office.MailboxEnums.ItemNotificationMessageType.InsightMessage,
1343413465
message: "This is an insight notification with id = " + id,
13435-
icon: "icon1",
13466+
icon: "PG.Icon.16",
1343613467
actions: [
1343713468
{
1343813469
actionText: "Open insight",
@@ -13495,7 +13526,7 @@
1349513526
{
1349613527
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
1349713528
message: "Non-persistent informational notification message with id = " + id,
13498-
icon: "icon1",
13529+
icon: "PG.Icon.16",
1349913530
persistent: false
1350013531
};
1350113532
Office.context.mailbox.item.notificationMessages.addAsync(id, details,
@@ -13513,7 +13544,7 @@
1351313544
{
1351413545
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
1351513546
message: "Persistent informational notification message with id = " + id,
13516-
icon: "icon1",
13547+
icon: "PG.Icon.16",
1351713548
persistent: true
1351813549
};
1351913550
Office.context.mailbox.item.notificationMessages.addAsync(id, details,

view-prod/outlook.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"outlook-get-item-class-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-class-async.yaml",
8484
"outlook-other-item-apis-item-id-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/item-id-compose.yaml",
8585
"outlook-send-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/send-async.yaml",
86+
"outlook-other-item-apis-get-loaded-message-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml",
8687
"outlook-get-set-isalldayevent": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml",
8788
"outlook-set-displayed-body-subject": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml"
8889
}

view/outlook.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"outlook-get-item-class-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-item-class-async.yaml",
8484
"outlook-other-item-apis-item-id-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/item-id-compose.yaml",
8585
"outlook-send-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/send-async.yaml",
86+
"outlook-other-item-apis-get-loaded-message-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml",
8687
"outlook-get-set-isalldayevent": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml",
8788
"outlook-set-displayed-body-subject": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml"
8889
}

0 commit comments

Comments
 (0)