Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
323 changes: 286 additions & 37 deletions docs/code-snippets/outlook-snippets.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2790,16 +2790,14 @@ methods:

// Get selected data.

Office.initialize = function () {
Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, {}, getCallback);
};
Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, { option1: "option1"}, getCallback);


function getCallback(asyncResult) {
const text = asyncResult.value.data;
const prop = asyncResult.value.sourceProperty;

console.log("Selected text in " + prop + ": " + text);
console.log(`Selected text in ${prop}: ${text}`);
}

```
Expand Down Expand Up @@ -3415,6 +3413,23 @@ methods:
**[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.removeHandlerAsync(Office.EventType.InfobarClicked, (asyncResult) => {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.error("Failed to remove event handler: " + asyncResult.error.message);
return;
}

console.log("Event handler removed successfully.");
});

```
isPreview: false
isDeprecated: false
syntax:
Expand Down
17 changes: 17 additions & 0 deletions docs/docs-ref-autogen/outlook/outlook/office.appointmentread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2931,6 +2931,23 @@ methods:
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!--
-->**: Appointment Attendee


#### Examples


```TypeScript

Office.context.mailbox.item.removeHandlerAsync(Office.EventType.InfobarClicked, (asyncResult) => {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.error("Failed to remove event handler: " + asyncResult.error.message);
return;
}

console.log("Event handler removed successfully.");
});

```
isPreview: false
isDeprecated: false
syntax:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,35 @@ fullName: Office.AppointmentTimeChangedEventArgs
summary: >-
Provides the current dates and times of the appointment that raised the `Office.EventType.AppointmentTimeChanged`
event.
remarks: '\[ [API set: Mailbox 1.7](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]'
remarks: |-
\[ [API set: Mailbox 1.7](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]

#### Examples

```TypeScript
// Adds an event handler for the AppointmentTimeChanged event.
Office.onReady(() => {
document.addEventListener('DOMContentLoaded', () => {
// Get a reference to the mailbox and use it to add an event handler.
const mailbox = Office.context.mailbox;
mailbox.addHandlerAsync(Office.EventType.AppointmentTimeChanged, appointmentTimeChangedHandler, (result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(`Failed to add event handler: ${asyncResult.error.message}`);
return;
}

console.log("Event handler added successfully.");
});
});
});

// Handles the AppointmentTimeChanged event.
function appointmentTimeChangedHandler(event) {
console.log(`Event: ${event.type}`);
console.log(`Start time: ${event.start}`);
console.log(`End time: ${event.end}`);
}
```
isPreview: false
isDeprecated: false
type: interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@ uid: 'outlook!Office.AttachmentsChangedEventArgs:interface'
package: outlook!
fullName: Office.AttachmentsChangedEventArgs
summary: Provides information about the attachment on a mail item that raised the `Office.EventType.AttachmentsChanged` event.
remarks: '\[ [API set: Mailbox 1.8](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]'
remarks: |-
\[ [API set: Mailbox 1.8](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]

#### Examples

```TypeScript
// Handles the OnMessageAttachmentsChanged event.
function onMessageAttachmentsChangedHandler(event) {
console.log(`Event: ${event.type}`);

if (event.attachmentStatus === Office.MailboxEnums.AttachmentStatus.Added) {
const attachment = event.attachmentDetails;
// Perform operations on the attachment that was added.
}
}
```
isPreview: false
isDeprecated: false
type: interface
Expand Down
52 changes: 48 additions & 4 deletions docs/docs-ref-autogen/outlook/outlook/office.body.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,50 @@ remarks: >-
**[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/20-item-body/add-inline-base64-image.yaml


const mailItem = Office.context.mailbox.item;

const base64String =
"iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAnUExURQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAN0S+bUAAAAMdFJOUwAQIDBAUI+fr7/P7yEupu8AAAAJcEhZcwAADsMAAA7DAcdvqGQAAAF8SURBVGhD7dfLdoMwDEVR6Cspzf9/b20QYOthS5Zn0Z2kVdY6O2WULrFYLBaLxd5ur4mDZD14b8ogWS/dtxV+dmx9ysA2QUj9TQRWv5D7HyKwuIW9n0vc8tkpHP0W4BOg3wQ8wtlvA+PC1e8Ao8Ld7wFjQtHvAiNC2e8DdqHqKwCrUPc1gE1AfRVgEXBfB+gF0lcCWoH2tYBOYPpqQCNwfT3QF9i+AegJfN8CtAWhbwJagtS3AbIg9o2AJMh9M5C+SVGBvx6zAfmT0r+Bv8JMwP4kyFPir+cswF5KL3WLv14zAFBCLf56Tw9cparFX4upgaJUtPhrOS1QlY5W+vWTXrGgBFB/b72ev3/0igUdQPppP/nfowfKUUEFcP207y/yxKmgAYQ+PywoAFOfCH3A2MdCFzD3kdADBvq10AGG+pXQBgb7pdAEhvuF0AIc/VtoAK7+JciAs38KIuDugyAC/v4hiMCE/i7IwLRBsh68N2WQjMVisVgs9i5bln8LGScNcCrONQAAAABJRU5ErkJggg==";

// Get the current body of the message or appointment.

mailItem.body.getAsync(Office.CoercionType.Html, (bodyResult) => {
if (bodyResult.status === Office.AsyncResultStatus.Succeeded) {
// Insert the Base64-encoded image to the beginning of the body.
const options = { isInline: true, asyncContext: bodyResult.value };
mailItem.addFileAttachmentFromBase64Async(base64String, "sample.png", options, (attachResult) => {
if (attachResult.status === Office.AsyncResultStatus.Succeeded) {
let body = attachResult.asyncContext;
body = body.replace("<p class=MsoNormal>", `<p class=MsoNormal><img src="cid:sample.png">`);

mailItem.body.setAsync(body, { coercionType: Office.CoercionType.Html }, (setResult) => {
if (setResult.status === Office.AsyncResultStatus.Succeeded) {
console.log("Inline Base64-encoded image added to the body.");
} else {
console.log(setResult.error.message);
}
});
} else {
console.log(attachResult.error.message);
}
});
} else {
console.log(bodyResult.error.message);
}
});

```
isPreview: false
isDeprecated: false
type: interface
Expand Down Expand Up @@ -370,7 +414,7 @@ methods:

mailItem.body.getAsync(Office.CoercionType.Html, (bodyResult) => {
if (bodyResult.status === Office.AsyncResultStatus.Succeeded) {
// Insert the Base64 image to the beginning of the body.
// Insert the Base64-encoded image to the beginning of the body.
const options = { isInline: true, asyncContext: bodyResult.value };
mailItem.addFileAttachmentFromBase64Async(base64String, "sample.png", options, (attachResult) => {
if (attachResult.status === Office.AsyncResultStatus.Succeeded) {
Expand All @@ -379,7 +423,7 @@ methods:

mailItem.body.setAsync(body, { coercionType: Office.CoercionType.Html }, (setResult) => {
if (setResult.status === Office.AsyncResultStatus.Succeeded) {
console.log("Inline Base64 image added to the body.");
console.log("Inline Base64-encoded image added to the body.");
} else {
console.log(setResult.error.message);
}
Expand Down Expand Up @@ -1056,7 +1100,7 @@ methods:

mailItem.body.getAsync(Office.CoercionType.Html, (bodyResult) => {
if (bodyResult.status === Office.AsyncResultStatus.Succeeded) {
// Insert the Base64 image to the beginning of the body.
// Insert the Base64-encoded image to the beginning of the body.
const options = { isInline: true, asyncContext: bodyResult.value };
mailItem.addFileAttachmentFromBase64Async(base64String, "sample.png", options, (attachResult) => {
if (attachResult.status === Office.AsyncResultStatus.Succeeded) {
Expand All @@ -1065,7 +1109,7 @@ methods:

mailItem.body.setAsync(body, { coercionType: Office.CoercionType.Html }, (setResult) => {
if (setResult.status === Office.AsyncResultStatus.Succeeded) {
console.log("Inline Base64 image added to the body.");
console.log("Inline Base64-encoded image added to the body.");
} else {
console.log(setResult.error.message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,42 @@ uid: 'outlook!Office.EnhancedLocationsChangedEventArgs:interface'
package: outlook!
fullName: Office.EnhancedLocationsChangedEventArgs
summary: Provides the current enhanced locations when the `Office.EventType.EnhancedLocationsChanged` event is raised.
remarks: '\[ [API set: Mailbox 1.8](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]'
remarks: |-
\[ [API set: Mailbox 1.8](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]

#### Examples

```TypeScript
// Adds an event handler for the EnhancedLocationsChanged event.
Office.onReady(() => {
document.addEventListener('DOMContentLoaded', () => {
// Get a reference to the mailbox and use it to add an event handler.
const mailbox = Office.context.mailbox;
mailbox.addHandlerAsync(Office.EventType.EnhancedLocationsChanged, enhancedLocationsChangedHandler, (result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(`Failed to add event handler: ${asyncResult.error.message}`);
return;
}

console.log("Event handler added successfully.");
});
});
});

// Handles the EnhancedLocationsChanged event.
function enhancedLocationsChangedHandler(event) {
console.log(`Event: ${event.type}`);
const enhancedLocations = event.enhancedLocations;
enhancedLocations.forEach((location) => {
console.log(`Display name: ${location.displayName}`);
const locationType = location.locationIdentifier.type;
console.log(`Type: ${locationType}`);
if (locationType === Office.MailboxEnums.LocationType.Room) {
console.log(`Email address: ${location.emailAddress}`);
}
});
}
```
isPreview: false
isDeprecated: false
type: interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,36 @@ uid: 'outlook!Office.InfobarClickedEventArgs:interface'
package: outlook!
fullName: Office.InfobarClickedEventArgs
summary: Provides basic details about the notification message that raised the `Office.EventType.InfobarClicked` event.
remarks: '\[ [API set: Mailbox 1.10](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]'
remarks: |-
\[ [API set: Mailbox 1.10](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]

#### Examples

```TypeScript
// Adds an event handler for the InfobarClicked event.
Office.onReady(() => {
document.addEventListener('DOMContentLoaded', () => {
// Get a reference to the mailbox and use it to add an event handler.
const mailbox = Office.context.mailbox;
mailbox.addHandlerAsync(Office.EventType.InfobarClicked, infobarClickedHandler, (result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(`Failed to add event handler: ${asyncResult.error.message}`);
return;
}

console.log("Event handler added successfully.");
});
});
});

// Handles the InfobarClicked event.
function infobarClickedHandler(event) {
console.log(`Event: ${event.type}`);
const infobarDetails = event.infobarDetails;
console.log(`Notification type: ${infobarDetails.infobarType}`);
console.log(`Action type: ${infobarDetails.actionType}`);
}
```
isPreview: false
isDeprecated: false
type: interface
Expand Down
36 changes: 35 additions & 1 deletion docs/docs-ref-autogen/outlook/outlook/office.infobardetails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,41 @@ uid: 'outlook!Office.InfobarDetails:interface'
package: outlook!
fullName: Office.InfobarDetails
summary: Provides additional details about the notification message that raised the `Office.EventType.InfobarClicked` event.
remarks: '\[ [API set: Mailbox 1.10](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]'
remarks: |-
\[ [API set: Mailbox 1.10](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets) \]

#### Examples

```TypeScript
/*
* This snippet activates when a notification message is dismissed from an Outlook message or appointment.
* The event handler logs the custom action and notification type to the console.
*/
Office.context.mailbox.item.addHandlerAsync(Office.EventType.InfobarClicked, eventHandler, callback);

function eventHandler(event) {
const infobarDetails = event.infobarDetails;

// Log the custom action type.
console.log(`Custom action type: ${infobarDetails.actionType}`);

// Log the notification type.
switch (infobarDetails.infobarType) {
case Office.MailboxEnums.InfobarType.Error:
console.log("Notification type: Error message");
break;
case Office.MailboxEnums.InfobarType.Informational:
console.log("Notification type: Informational message");
break;
case Office.MailboxEnums.InfobarType.Insight:
console.log("Notification type: Informational message with available actions from the task pane");
break;
case Office.MailboxEnums.InfobarType.ProgressIndicator:
console.log("Notification type: Progress indicator");
break;
}
}
```
isPreview: false
isDeprecated: false
type: interface
Expand Down
Loading