Skip to content

Commit f8c6cc9

Browse files
[Outlook] Adding code snippet example of the new sendAsync API (#950)
* Adding code snippet example of the new sendAsync API to send message and appointments * Adding yaml file * Update samples/outlook/99-preview-apis/send-async.yaml Co-authored-by: Sam Ramon <[email protected]> * Update samples/outlook/99-preview-apis/send-async.yaml Co-authored-by: Sam Ramon <[email protected]> --------- Co-authored-by: Sam Ramon <[email protected]>
1 parent 864521f commit f8c6cc9

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
lines changed

playlists-prod/outlook.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,15 @@
793793
group: Preview APIs
794794
api_set:
795795
Mailbox: preview
796+
- id: outlook-send-async
797+
name: Send the current message or appointment (Compose)
798+
fileName: send-async.yaml
799+
description: Send the current message or appointment.
800+
rawUrl: >-
801+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/send-async.yaml
802+
group: Preview APIs
803+
api_set:
804+
Mailbox: preview
796805
- id: outlook-set-displayed-body-subject
797806
name: Temporarily set the body or subject displayed in a message (Message Read)
798807
fileName: set-displayed-body-subject.yaml

playlists/outlook.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,15 @@
793793
group: Preview APIs
794794
api_set:
795795
Mailbox: preview
796+
- id: outlook-send-async
797+
name: Send the current message or appointment (Compose)
798+
fileName: send-async.yaml
799+
description: Send the current message or appointment.
800+
rawUrl: >-
801+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/send-async.yaml
802+
group: Preview APIs
803+
api_set:
804+
Mailbox: preview
796805
- id: outlook-set-displayed-body-subject
797806
name: Temporarily set the body or subject displayed in a message (Message Read)
798807
fileName: set-displayed-body-subject.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
order: 2
2+
id: outlook-send-async
3+
name: Send the current message or appointment (Compose)
4+
description: Sends the current message or appointment.
5+
host: OUTLOOK
6+
api_set:
7+
Mailbox: preview
8+
script:
9+
content: |
10+
$("#send-async").on("click", sendAsync);
11+
12+
function sendAsync() {
13+
// This snippet sends the current message or appointment being composed.
14+
Office.context.mailbox.item.sendAsync((asyncResult) => {
15+
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
16+
console.log("Action failed with error: " + asyncResult.error.message);
17+
return;
18+
}
19+
});
20+
}
21+
language: typescript
22+
template:
23+
content: |-
24+
<section class="ms-Fabric ms-font-m">
25+
<p class="ms-font-m">This sample shows how to programmatically send the current message or appointment being composed.</p>
26+
<p><b>Required mode</b>: Compose</p>
27+
</section>
28+
29+
<section class="ms-Fabric samples ms-font-m">
30+
<h3>Try it out</h3>
31+
<button id="send-async" class="ms-Button">
32+
<span class="ms-Button-label">Send</span>
33+
</button>
34+
</section>
35+
language: html
36+
style:
37+
content: |-
38+
section.samples {
39+
margin-top: 20px;
40+
}
41+
42+
section.samples .ms-Button, section.setup .ms-Button {
43+
display: block;
44+
margin-bottom: 5px;
45+
margin-left: 20px;
46+
min-width: 80px;
47+
}
48+
language: css
49+
libraries: |-
50+
https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
51+
@types/office-js-preview
52+
53+
[email protected]/dist/css/fabric.min.css
54+
[email protected]/dist/css/fabric.components.min.css
55+
56+
[email protected]/client/core.min.js
57+
@types/core-js
58+
59+
60+

view-prod/outlook.json

+1
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@
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-get-set-isalldayevent": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml",
86+
"outlook-send-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/send-async.yaml",
8687
"outlook-set-displayed-body-subject": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml"
8788
}

view/outlook.json

+1
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@
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-get-set-isalldayevent": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml",
86+
"outlook-send-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/send-async.yaml",
8687
"outlook-set-displayed-body-subject": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml"
8788
}

0 commit comments

Comments
 (0)