-
Notifications
You must be signed in to change notification settings - Fork 61
/
office.customproperties.yml
363 lines (257 loc) · 12.6 KB
/
office.customproperties.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
### YamlMime:TSType
name: Office.CustomProperties
uid: 'outlook!Office.CustomProperties:interface'
package: outlook!
fullName: Office.CustomProperties
summary: >-
The `CustomProperties` object represents custom properties that are specific to a particular mail item and specific to
an Outlook add-in. For example, there might be a need for an add-in to save some data that's specific to the current
message that activated the add-in. If the user revisits the same message in the future and activates the add-in again,
the add-in will be able to retrieve the data that had been saved as custom properties.
To learn more about `CustomProperties`<!-- -->, see [Get and set add-in metadata for an Outlook
add-in](https://learn.microsoft.com/office/dev/add-ins/outlook/metadata-for-an-outlook-add-in)<!-- -->.
remarks: >-
\[ [API set: Mailbox 1.1](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]
When using custom properties in your add-in, keep in mind that:
- Custom properties saved while in compose mode aren't transmitted to recipients of the mail item. When a message or
appointment with custom properties is sent, its properties can be accessed from the item in the Sent Items folder. If
you want to make custom data accessible to recipients, consider using
[InternetHeaders](https://learn.microsoft.com/javascript/api/outlook/office.internetheaders) instead.
- The maximum length of a `CustomProperties` JSON object is 2500 characters.
- Outlook on Mac doesn't cache custom properties. If the user's network goes down, mail add-ins can't access their
custom properties.
**[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)<!-- -->**:
Compose or Read
isPreview: false
isDeprecated: false
type: interface
methods:
- name: get(name)
uid: 'outlook!Office.CustomProperties#get:member(1)'
package: outlook!
fullName: get(name)
summary: Returns the value of the specified custom property.
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)<!--
-->**: Compose or Read
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml
const propertyName = $("#get-property-name").val();
const propertyValue = customProps.get(propertyName);
console.log(`The value of custom property "${propertyName}" is "${propertyValue}".`);
```
isPreview: false
isDeprecated: false
syntax:
content: 'get(name: string): any;'
parameters:
- id: name
description: The name of the custom property to be returned.
type: string
return:
type: any
description: The value of the specified custom property.
- name: getAll()
uid: 'outlook!Office.CustomProperties#getAll:member(1)'
package: outlook!
fullName: getAll()
summary: |-
Returns an object with all custom properties in a collection of name/value pairs. The following are equivalent.
`customProps.get("name")`
`var dictionary = customProps.getAll(); dictionary["name"]`
You can iterate through the dictionary object to discover all `names` and `values`<!-- -->.
remarks: >-
\[ [API set: Mailbox 1.9](/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)<!--
-->**: Compose or Read
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml
let allCustomProps;
if (Office.context.requirements.isSetSupported("Mailbox", "1.9")) {
allCustomProps = customProps.getAll();
} else {
allCustomProps = customProps["rawData"];
}
console.log(allCustomProps);
```
isPreview: false
isDeprecated: false
syntax:
content: 'getAll(): any;'
return:
type: any
description: An object with all custom properties in a collection of name/value pairs.
- name: remove(name)
uid: 'outlook!Office.CustomProperties#remove:member(1)'
package: outlook!
fullName: remove(name)
summary: >-
Removes the specified property from the custom property collection.
To make the removal of the property permanent, you must call the `saveAsync` method of the `CustomProperties`
object.
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)<!--
-->**: Compose or Read
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml
const propertyName = $("#remove-property-name").val();
customProps.remove(propertyName);
console.log(`Custom property "${propertyName}" removed.`);
```
isPreview: false
isDeprecated: false
syntax:
content: 'remove(name: string): void;'
parameters:
- id: name
description: The `name` of the property to be removed.
type: string
return:
type: void
description: ''
- name: 'saveAsync(callback, asyncContext)'
uid: 'outlook!Office.CustomProperties#saveAsync:member(1)'
package: outlook!
fullName: 'saveAsync(callback, asyncContext)'
summary: >-
Saves custom properties to a message or appointment.
You must call the `saveAsync` method to persist any changes made with the `set` method or the `remove` method of
the `CustomProperties` object. The saving action is asynchronous.
It's a good practice to have your callback function check for and handle errors from `saveAsync`<!-- -->. In
particular, a read add-in can be activated while the user is in a connected state in a read form, and subsequently
the user becomes disconnected. If the add-in calls `saveAsync` while in the disconnected state, `saveAsync` would
return an error. Your callback function should handle this error accordingly.
remarks: >-
\[ [API set: Mailbox 1.1](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]
**Important**: In Outlook on Windows, custom properties saved while in compose mode only persist after the
item being composed is closed or after `Office.context.mailbox.item.saveAsync` is called.
**[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)<!--
-->**: Compose or Read
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml
customProps.saveAsync((result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(`saveAsync failed with message ${result.error.message}`);
return;
}
console.log(`Custom properties saved with status: ${result.status}`);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'saveAsync(callback: (asyncResult: Office.AsyncResult<void>) => void, asyncContext?: any): void;'
parameters:
- id: callback
description: >-
When the method completes, the function passed in the `callback` parameter is called with a single parameter
of type `Office.AsyncResult`<!-- -->.
type: '(asyncResult: <xref uid="office!Office.AsyncResult:interface" /><void>) => void'
- id: asyncContext
description: Optional. Any state data that is passed to the callback function.
type: any
return:
type: void
description: ''
- name: saveAsync(asyncContext)
uid: 'outlook!Office.CustomProperties#saveAsync:member(2)'
package: outlook!
fullName: saveAsync(asyncContext)
summary: >-
Saves custom properties to a message or appointment.
You must call the `saveAsync` method to persist any changes made with the `set` method or the `remove` method of
the `CustomProperties` object. The saving action is asynchronous.
It's a good practice to have your callback function check for and handle errors from `saveAsync`<!-- -->. In
particular, a read add-in can be activated while the user is in a connected state in a read form, and subsequently
the user becomes disconnected. If the add-in calls `saveAsync` while in the disconnected state, `saveAsync` would
return an error. Your callback function should handle this error accordingly.
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)<!--
-->**: Compose or Read
isPreview: false
isDeprecated: false
syntax:
content: 'saveAsync(asyncContext?: any): void;'
parameters:
- id: asyncContext
description: Optional. Any state data that is passed to the callback function.
type: any
return:
type: void
description: ''
- name: 'set(name, value)'
uid: 'outlook!Office.CustomProperties#set:member(1)'
package: outlook!
fullName: 'set(name, value)'
summary: >-
Sets the specified property to the specified value.
The `set` method sets the specified property to the specified value. To ensure that the set property and value
persist on the mail item, you must call the `saveAsync` method.
The `set` method creates a new property if the specified property does not already exist; otherwise, the existing
value is replaced with the new value. The `value` parameter can be of any type; however, it is always passed to
the server as a string.
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)<!--
-->**: Compose or Read
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml
const propertyName = $("#set-property-name").val();
const propertyValue = $("#property-value").val();
customProps.set(propertyName, propertyValue);
console.log(`Custom property "${propertyName}" set to value "${propertyValue}".`);
```
isPreview: false
isDeprecated: false
syntax:
content: 'set(name: string, value: string): void;'
parameters:
- id: name
description: The name of the property to be set.
type: string
- id: value
description: The value of the property to be set.
type: string
return:
type: void
description: ''