/
office.appointmentcompose.yml
1528 lines (1129 loc) · 57.4 KB
/
office.appointmentcompose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
### YamlMime:TSType
name: Office.AppointmentCompose
uid: 'outlook!Office.AppointmentCompose:interface'
package: outlook!
fullName: Office.AppointmentCompose
summary: >-
The appointment organizer mode of [Office.context.mailbox.item](xref:outlook!Office.Item:interface)<!-- -->.
**Important**: This is an internal Outlook object, not directly exposed through existing interfaces. You should
treat this as a mode of `Office.context.mailbox.item`<!-- -->. For more information, refer to the [Object
Model](https://learn.microsoft.com/javascript/api/requirement-sets/outlook/requirement-set-1.2/office.context.mailbox.item)
page.
Parent interfaces:
- [ItemCompose](xref:outlook!Office.ItemCompose:interface)
- [Appointment](xref:outlook!Office.Appointment:interface)
remarks: ''
isPreview: false
isDeprecated: false
type: interface
properties:
- name: body
uid: 'outlook!Office.AppointmentCompose#body:member'
package: outlook!
fullName: body
summary: Gets an object that provides methods for manipulating the body of an item.
remarks: >-
\[ [API set: Mailbox 1.1](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
#### Examples
```TypeScript
// This example gets the body of the item as plain text.
Office.context.mailbox.item.body.getAsync(
"text",
{ asyncContext: "This is passed to the callback" },
function callback(result) {
// Do something with the result.
});
// The following is an example of an object that is passed as the result parameter to the callback function.
{
"value": "TEXT of whole body (including threads below)",
"status": "succeeded",
"asyncContext": "This is passed to the callback"
}
```
isPreview: false
isDeprecated: false
syntax:
content: 'body: Body;'
return:
type: '<xref uid="outlook!Office.Body:interface" />'
- name: end
uid: 'outlook!Office.AppointmentCompose#end:member'
package: outlook!
fullName: end
summary: >-
Gets or sets the date and time that the appointment is to end.
The `end` property is a [Time](xref:outlook!Office.Time:interface) object expressed as a Coordinated Universal
Time (UTC) date and time value. You can use the `convertToLocalClientTime` method to convert the `end` property
value to the client's local date and time.
When you use the `Time.setAsync` method to set the end time, you should use the `convertToUtcClientTime` method to
convert the local time on the client to UTC for the server.
**Important**: In the Windows client, you can't use this property to update the end of a recurrence.
remarks: >-
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
#### Examples
```TypeScript
// The following example sets the end time of an appointment in compose mode by
// using the `setAsync` method of the `Time` object.
const endTime = new Date("3/14/2015");
const options = {
// Pass information that can be used in the callback.
asyncContext: {verb: "Set"}
};
Office.context.mailbox.item.end.setAsync(endTime, options, function(result) {
if (result.error) {
console.debug(result.error);
} else {
// Access the asyncContext that was passed to the setAsync method.
console.debug("End Time " + result.asyncContext.verb);
}
});
```
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml
Office.context.mailbox.item.end.getAsync((result) => {
if (result.status !== Office.AsyncResultStatus.Succeeded) {
console.error(`Action failed with message ${result.error.message}`);
return;
}
console.log(`Appointment ends: ${result.value}`);
});
...
Office.context.mailbox.item.start.getAsync((result) => {
if (result.status !== Office.AsyncResultStatus.Succeeded) {
console.error(`Get start date failed with message ${result.error.message}`);
return;
}
const end = result.value; // Set end to current start date and time.
end.setDate(end.getDate() + 1); // Set end as 1 day later than start date.
Office.context.mailbox.item.end.setAsync(end, (result) => {
if (result.status !== Office.AsyncResultStatus.Succeeded) {
console.error(`Set end date failed with message ${result.error.message}`);
return;
}
console.log(`Successfully set end date and time to ${end}`);
});
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'end: Time;'
return:
type: '<xref uid="outlook!Office.Time:interface" />'
- name: itemType
uid: 'outlook!Office.AppointmentCompose#itemType:member'
package: outlook!
fullName: itemType
summary: >-
Gets the type of item that an instance represents.
The `itemType` property returns one of the `ItemType` enumeration values, indicating whether the `item` object
instance is a message or an appointment.
remarks: >-
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml
const itemType = Office.context.mailbox.item.itemType;
switch (itemType) {
case Office.MailboxEnums.ItemType.Appointment:
console.log(`Current item is an ${itemType}.`);
break;
case Office.MailboxEnums.ItemType.Message:
console.log(`Current item is a ${itemType}. A message could be an email, meeting request, meeting response, or meeting cancellation.`);
break;
}
```
isPreview: false
isDeprecated: false
syntax:
content: 'itemType: MailboxEnums.ItemType | string;'
return:
type: '<xref uid="outlook!Office.MailboxEnums.ItemType:enum" /> | string'
- name: location
uid: 'outlook!Office.AppointmentCompose#location:member'
package: outlook!
fullName: location
summary: >-
Gets or sets the location of an appointment. The `location` property returns a
[Location](xref:outlook!Office.Location:interface) object that provides methods that are used to get and set the
location of the appointment.
remarks: >-
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
#### Examples
```TypeScript
const userContext = { value : 1 };
Office.context.mailbox.item.location.getAsync( { context: userContext}, callback);
function callback(asyncResult) {
const context = asyncResult.context;
const location = asyncResult.value;
}
```
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml
Office.context.mailbox.item.location.getAsync((result) => {
if (result.status !== Office.AsyncResultStatus.Succeeded) {
console.error(`Action failed with message ${result.error.message}`);
return;
}
console.log(`Appointment location: ${result.value}`);
});
...
const location = "my office";
Office.context.mailbox.item.location.setAsync(location, (result) => {
if (result.status !== Office.AsyncResultStatus.Succeeded) {
console.error(`Action failed with message ${result.error.message}`);
return;
}
console.log(`Successfully set location to ${location}`);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'location: Location;'
return:
type: '<xref uid="outlook!Office.Location:interface" />'
- name: optionalAttendees
uid: 'outlook!Office.AppointmentCompose#optionalAttendees:member'
package: outlook!
fullName: optionalAttendees
summary: >-
Provides access to the optional attendees of an event. The type of object and level of access depend on the mode
of the current item.
The `optionalAttendees` property returns a `Recipients` object that provides methods to get or update the optional
attendees for a meeting. However, depending on the client/platform (i.e., Windows, Mac, etc.), limits may apply on
how many recipients you can get or update. See the [Recipients](xref:outlook!Office.Recipients:interface) object
for more details.
remarks: >-
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
#### Examples
```TypeScript
Office.context.mailbox.item.optionalAttendees.setAsync( ['alice@contoso.com', 'bob@contoso.com'] );
Office.context.mailbox.item.optionalAttendees.addAsync( ['jason@contoso.com'] );
Office.context.mailbox.item.optionalAttendees.getAsync(callback);
function callback(asyncResult) {
const arrayOfOptionalAttendeesRecipients = asyncResult.value;
}
```
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml
Office.context.mailbox.item.optionalAttendees.getAsync(function(asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
const apptOptionalAttendees = asyncResult.value;
for (let i = 0; i < apptOptionalAttendees.length; i++) {
console.log(
"Optional attendees: " +
apptOptionalAttendees[i].displayName +
" (" +
apptOptionalAttendees[i].emailAddress +
") - response: " +
apptOptionalAttendees[i].appointmentResponse
);
}
} else {
console.error(asyncResult.error);
}
});
...
const email = $("#emailOptional")
.val()
.toString();
const emailArray = [email];
Office.context.mailbox.item.optionalAttendees.setAsync(emailArray, function(asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
console.log("Succeeded in setting optional attendees field.");
} else {
console.error(asyncResult.error);
}
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'optionalAttendees: Recipients;'
return:
type: '<xref uid="outlook!Office.Recipients:interface" />'
- name: requiredAttendees
uid: 'outlook!Office.AppointmentCompose#requiredAttendees:member'
package: outlook!
fullName: requiredAttendees
summary: >-
Provides access to the required attendees of an event. The type of object and level of access depend on the mode
of the current item.
The `requiredAttendees` property returns a `Recipients` object that provides methods to get or update the required
attendees for a meeting. However, depending on the client/platform (i.e., Windows, Mac, etc.), limits may apply on
how many recipients you can get or update. See the [Recipients](xref:outlook!Office.Recipients:interface) object
for more details.
remarks: >-
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
#### Examples
```TypeScript
Office.context.mailbox.item.requiredAttendees.setAsync( ['alice@contoso.com', 'bob@contoso.com'] );
Office.context.mailbox.item.requiredAttendees.addAsync( ['jason@contoso.com'] );
Office.context.mailbox.item.requiredAttendees.getAsync(callback);
function callback(asyncResult) {
const arrayOfRequiredAttendeesRecipients = asyncResult.value;
console.log(JSON.stringify(arrayOfRequiredAttendeesRecipients));
}
```
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml
Office.context.mailbox.item.requiredAttendees.getAsync(function(asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
const apptRequiredAttendees = asyncResult.value;
for (let i = 0; i < apptRequiredAttendees.length; i++) {
console.log(
"Required attendees: " +
apptRequiredAttendees[i].displayName +
" (" +
apptRequiredAttendees[i].emailAddress +
") - response: " +
apptRequiredAttendees[i].appointmentResponse
);
}
} else {
console.error(asyncResult.error);
}
});
...
const email = $("#emailRequired")
.val()
.toString();
const emailArray = [email];
Office.context.mailbox.item.requiredAttendees.setAsync(emailArray, function(asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
console.log("Succeeded in setting required attendees field.");
} else {
console.error(asyncResult.error);
}
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'requiredAttendees: Recipients;'
return:
type: '<xref uid="outlook!Office.Recipients:interface" />'
- name: start
uid: 'outlook!Office.AppointmentCompose#start:member'
package: outlook!
fullName: start
summary: >-
Gets or sets the date and time that the appointment is to begin.
The `start` property is a [Time](xref:outlook!Office.Time:interface) object expressed as a Coordinated Universal
Time (UTC) date and time value. You can use the `convertToLocalClientTime` method to convert the value to the
client's local date and time.
When you use the `Time.setAsync` method to set the start time, you should use the `convertToUtcClientTime` method
to convert the local time on the client to UTC for the server.
**Important**: In the Windows client, you can't use this property to update the start of a recurrence.
remarks: >-
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml
Office.context.mailbox.item.start.getAsync((result) => {
if (result.status !== Office.AsyncResultStatus.Succeeded) {
console.error(`Action failed with message ${result.error.message}`);
return;
}
console.log(`Appointment starts: ${result.value}`);
});
...
const start = new Date(); // Represents current date and time.
start.setDate(start.getDate() + 2); // Add 2 days to current date.
Office.context.mailbox.item.start.setAsync(start, (result) => {
if (result.status !== Office.AsyncResultStatus.Succeeded) {
console.error(`Action failed with message ${result.error.message}`);
return;
}
console.log(`Successfully set start date and time to ${start}`);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'start: Time;'
return:
type: '<xref uid="outlook!Office.Time:interface" />'
- name: subject
uid: 'outlook!Office.AppointmentCompose#subject:member'
package: outlook!
fullName: subject
summary: |-
Gets or sets the description that appears in the subject field of an item.
The `subject` property gets or sets the entire subject of the item, as sent by the email server.
The `subject` property returns a `Subject` object that provides methods to get and set the subject.
remarks: >-
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml
Office.context.mailbox.item.subject.getAsync((result) => {
if (result.status !== Office.AsyncResultStatus.Succeeded) {
console.error(`Action failed with message ${result.error.message}`);
return;
}
console.log(`Subject: ${result.value}`);
});
...
let subject = "Hello World!";
Office.context.mailbox.item.subject.setAsync(subject, (result) => {
if (result.status !== Office.AsyncResultStatus.Succeeded) {
console.error(`Action failed with message ${result.error.message}`);
return;
}
console.log(`Successfully set subject to ${subject}`);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'subject: Subject;'
return:
type: '<xref uid="outlook!Office.Subject:interface" />'
methods:
- name: 'addFileAttachmentAsync(uri, attachmentName, options, callback)'
uid: 'outlook!Office.AppointmentCompose#addFileAttachmentAsync:member(1)'
package: outlook!
fullName: 'addFileAttachmentAsync(uri, attachmentName, options, callback)'
summary: >-
Adds a file to a message or appointment as an attachment.
The `addFileAttachmentAsync` method uploads the file at the specified URI and attaches it to the item in the
compose form.
You can subsequently use the identifier with the `removeAttachmentAsync` method to remove the attachment in the
same session.
**Important**: In recent builds of Outlook on Windows, a bug was introduced that incorrectly appends an
`Authorization: Bearer` header to this action (whether using this API or the Outlook UI). To work around this
issue, you can try using the `addFileAttachmentFromBase64` API introduced with requirement set 1.8.
remarks: >-
\[ [API set: Mailbox 1.1](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read/write item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
**Errors**:
- `AttachmentSizeExceeded`<!-- -->: The attachment is larger than allowed.
- `FileTypeNotSupported`<!-- -->: The attachment has an extension that is not allowed.
- `NumberOfAttachmentsExceeded`<!-- -->: The message or appointment has too many attachments.
#### Examples
```TypeScript
function callback(result) {
if (result.error) {
console.log(result.error);
} else {
console.log("Attachment added");
}
}
function addAttachment() {
// The values in asyncContext can be accessed in the callback.
const options = { 'asyncContext': { var1: 1, var2: 2 } };
const attachmentURL = "https://contoso.com/rtm/icon.png";
Office.context.mailbox.item.addFileAttachmentAsync(attachmentURL, attachmentURL, options, callback);
}
```
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml
const attachmentUrl = $("#attachmentUrl").val();
Office.context.mailbox.item.addFileAttachmentAsync(
attachmentUrl,
getFileName(attachmentUrl),
{ "asyncContext" : { var1: 1, var2: true } },
function(result) { console.log(result); });
```
isPreview: false
isDeprecated: false
syntax:
content: >-
addFileAttachmentAsync(uri: string, attachmentName: string, options: Office.AsyncContextOptions & { isInline:
boolean }, callback?: (asyncResult: Office.AsyncResult<string>) => void): void;
parameters:
- id: uri
description: >-
The URI that provides the location of the file to attach to the message or appointment. The maximum length
is 2048 characters.
type: string
- id: attachmentName
description: >-
The name of the attachment that is shown while the attachment is uploading. The maximum length is 255
characters.
type: string
- id: options
description: >-
An object literal that contains one or more of the following properties:- `asyncContext`<!-- -->: Developers
can provide any object they wish to access in the callback function. `isInline`<!-- -->: If true, indicates
that the attachment will be shown inline in the message body, and should not be displayed in the attachment
list.
type: '<xref uid="office!Office.AsyncContextOptions:interface" /> & { isInline: boolean }'
- id: callback
description: >-
Optional. When the method completes, the function passed in the `callback` parameter is called with a single
parameter of type `Office.AsyncResult`<!-- -->. On success, the attachment identifier will be provided in
the `asyncResult.value` property. If uploading the attachment fails, the `asyncResult` object will contain
an `Error` object that provides a description of the error.
type: '(asyncResult: <xref uid="office!Office.AsyncResult:interface" /><string>) => void'
return:
type: void
description: ''
- name: 'addFileAttachmentAsync(uri, attachmentName, callback)'
uid: 'outlook!Office.AppointmentCompose#addFileAttachmentAsync:member(2)'
package: outlook!
fullName: 'addFileAttachmentAsync(uri, attachmentName, callback)'
summary: >-
Adds a file to a message or appointment as an attachment.
The `addFileAttachmentAsync` method uploads the file at the specified URI and attaches it to the item in the
compose form.
You can subsequently use the identifier with the `removeAttachmentAsync` method to remove the attachment in the
same session.
**Important**: In recent builds of Outlook on Windows, a bug was introduced that incorrectly appends an
`Authorization: Bearer` header to this action (whether using this API or the Outlook UI). To work around this
issue, you can try using the `addFileAttachmentFromBase64` API introduced with requirement set 1.8.
remarks: >-
\[ [API set: Mailbox 1.1](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read/write item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
**Errors**:
- `AttachmentSizeExceeded`<!-- -->: The attachment is larger than allowed.
- `FileTypeNotSupported`<!-- -->: The attachment has an extension that is not allowed.
- `NumberOfAttachmentsExceeded`<!-- -->: The message or appointment has too many attachments.
isPreview: false
isDeprecated: false
syntax:
content: >-
addFileAttachmentAsync(uri: string, attachmentName: string, callback?: (asyncResult:
Office.AsyncResult<string>) => void): void;
parameters:
- id: uri
description: >-
The URI that provides the location of the file to attach to the message or appointment. The maximum length
is 2048 characters.
type: string
- id: attachmentName
description: >-
The name of the attachment that is shown while the attachment is uploading. The maximum length is 255
characters.
type: string
- id: callback
description: >-
Optional. When the method completes, the function passed in the `callback` parameter is called with a single
parameter of type `Office.AsyncResult`<!-- -->. On success, the attachment identifier will be provided in
the `asyncResult.value` property. If uploading the attachment fails, the `asyncResult` object will contain
an `Error` object that provides a description of the error.
type: '(asyncResult: <xref uid="office!Office.AsyncResult:interface" /><string>) => void'
return:
type: void
description: ''
- name: 'addItemAttachmentAsync(itemId, attachmentName, options, callback)'
uid: 'outlook!Office.AppointmentCompose#addItemAttachmentAsync:member(1)'
package: outlook!
fullName: 'addItemAttachmentAsync(itemId, attachmentName, options, callback)'
summary: >-
Adds an Exchange item, such as a message, as an attachment to the message or appointment.
The `addItemAttachmentAsync` method attaches the item with the specified Exchange identifier to the item in the
compose form. If you specify a callback function, the method is called with one parameter, `asyncResult`<!-- -->,
which contains either the attachment identifier or a code that indicates any error that occurred while attaching
the item. You can use the `options` parameter to pass state information to the callback function, if needed.
You can subsequently use the identifier with the `removeAttachmentAsync` method to remove the attachment in the
same session.
If your Office Add-in is running in Outlook on the web, the `addItemAttachmentAsync` method can attach items to
items other than the item that you are editing; however, this is not supported and is not recommended.
remarks: >-
\[ [API set: Mailbox 1.1](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read/write item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
**Errors**:
- `NumberOfAttachmentsExceeded`<!-- -->: The message or appointment has too many attachments.
#### Examples
```TypeScript
// The following example adds an existing Outlook item as an attachment
// with the name `My Attachment`.
function callback(result) {
if (result.error) {
console.log(result.error);
} else {
console.log("Attachment added");
}
}
function addAttachment() {
// EWS ID of item to attach (shortened for readability).
const itemId = "AAMkADI1...AAA=";
// The values in asyncContext can be accessed in the callback.
const options = { 'asyncContext': { var1: 1, var2: 2 } };
Office.context.mailbox.item.addItemAttachmentAsync(itemId, "My Attachment", options, callback);
}
```
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml
const attachmentItemId = $("#attachmentItemId").val();
Office.context.mailbox.item.addItemAttachmentAsync(
attachmentItemId,
"My attachment",
{ "asyncContext" : { var3: 3, var4: false } },
function(result) { console.log(result); });
```
isPreview: false
isDeprecated: false
syntax:
content: >-
addItemAttachmentAsync(itemId: any, attachmentName: string, options: Office.AsyncContextOptions, callback?:
(asyncResult: Office.AsyncResult<string>) => void): void;
parameters:
- id: itemId
description: The Exchange identifier of the item to attach. The maximum length is 100 characters.
type: any
- id: attachmentName
description: >-
The name of the attachment that is shown while the attachment is uploading. The maximum length is 255
characters.
type: string
- id: options
description: >-
An object literal that contains one or more of the following properties:- `asyncContext`<!-- -->: Developers
can provide any object they wish to access in the callback function.
type: '<xref uid="office!Office.AsyncContextOptions:interface" />'
- id: callback
description: >-
Optional. When the method completes, the function passed in the callback parameter is called with a single
parameter of type `Office.AsyncResult`<!-- -->. On success, the attachment identifier will be provided in
the `asyncResult.value` property. If adding the attachment fails, the `asyncResult` object will contain an
`Error` object that provides a description of the error.
type: '(asyncResult: <xref uid="office!Office.AsyncResult:interface" /><string>) => void'
return:
type: void
description: ''
- name: 'addItemAttachmentAsync(itemId, attachmentName, callback)'
uid: 'outlook!Office.AppointmentCompose#addItemAttachmentAsync:member(2)'
package: outlook!
fullName: 'addItemAttachmentAsync(itemId, attachmentName, callback)'
summary: >-
Adds an Exchange item, such as a message, as an attachment to the message or appointment.
The `addItemAttachmentAsync` method attaches the item with the specified Exchange identifier to the item in the
compose form. If you specify a callback function, the method is called with one parameter, `asyncResult`<!-- -->,
which contains either the attachment identifier or a code that indicates any error that occurred while attaching
the item. You can use the `options` parameter to pass state information to the callback function, if needed.
You can subsequently use the identifier with the `removeAttachmentAsync` method to remove the attachment in the
same session.
If your Office Add-in is running in Outlook on the web, the `addItemAttachmentAsync` method can attach items to
items other than the item that you are editing; however, this is not supported and is not recommended.
remarks: >-
\[ [API set: Mailbox 1.1](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read/write item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
**Errors**:
- `NumberOfAttachmentsExceeded`<!-- -->: The message or appointment has too many attachments.
isPreview: false
isDeprecated: false
syntax:
content: >-
addItemAttachmentAsync(itemId: any, attachmentName: string, callback?: (asyncResult:
Office.AsyncResult<string>) => void): void;
parameters:
- id: itemId
description: The Exchange identifier of the item to attach. The maximum length is 100 characters.
type: any
- id: attachmentName
description: >-
The name of the attachment that is shown while the attachment is uploading. The maximum length is 255
characters.
type: string
- id: callback
description: >-
Optional. When the method completes, the function passed in the callback parameter is called with a single
parameter of type `Office.AsyncResult`<!-- -->. On success, the attachment identifier will be provided in
the `asyncResult.value` property. If adding the attachment fails, the `asyncResult` object will contain an
`Error` object that provides a description of the error.
type: '(asyncResult: <xref uid="office!Office.AsyncResult:interface" /><string>) => void'
return:
type: void
description: ''
- name: 'getSelectedDataAsync(coercionType, options, callback)'
uid: 'outlook!Office.AppointmentCompose#getSelectedDataAsync:member(1)'
package: outlook!
fullName: 'getSelectedDataAsync(coercionType, options, callback)'
summary: >-
Asynchronously returns selected data from the subject or body of a message.
If there is no selection but the cursor is in the body or subject, the method returns an empty string for the
selected data. If a field other than the body or subject is selected, the method returns the `InvalidSelection`
error.
To access the selected data from the callback function, call `asyncResult.value.data`<!-- -->. To access the
`source` property that the selection comes from, call `asyncResult.value.sourceProperty`<!-- -->, which will be
either `body` or `subject`<!-- -->.
remarks: >-
\[ [API set: Mailbox 1.2](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]
**[Minimum permission
level](https://learn.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions)<!--
-->**: **read item**
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Organizer
#### Examples
```TypeScript