Outlook Integration
Usage
theme: 'ios' You can turn auto theming on and let it decide based on the platform.
Usage
themeVariant: 'light' You can turn auto dark mode on based on system settings.
Usage
clickToCreate: true,
// click to create is on dragToCreate: true,
// drag to create is on dragToMove: true,
// reordering is on dragToResize: true,
// resizing is on eventDelete: true
// deleting is on Fine-tune drag & drop with these options, which are false by default.
Usage
locale: localeEn Selecting the locale loads the localized settings and the translated UI text.
Outlook Integration
The event calendar comes with third party calendar integration support through the integration plugin. This needs to be added to the download package or installed separately from a dedicated NPM package.
It includes everything you need to authenticate your users, get their Outlook calendars and provides functions for CRUD operations. It takes care of loading the events and converts them to the required format so that they can be displayed on the Mobiscroll calendar separately or mixed with other calendars and events.
Customizing the interaction, event workflows, whether the events are read-only is up to you. In this live demo, newly created events will land in the primary calendar of the authenticated user.
Demo
The live demo didn't load.
Try it on demo.mobiscroll.comLog into your Outlook account to view and edit your Outlook Calendar events
Editing events sync back to your calendar when enabled. You'll be asked for confirmation on every action.

Code
import { CommonModule } from '@angular/common';
import { Component, NgZone, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MbscCalendarEvent, MbscEventcalendarOptions, MbscModule, Notifications, setOptions } from '@mobiscroll/angular';
import { outlookCalendarSync } from '@mobiscroll/calendar-integration';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
providers: [Notifications],
standalone: true,
imports: [CommonModule, FormsModule, MbscModule],
})
export class AppComponent implements OnInit {
constructor(
public notify: Notifications,
public zone: NgZone,
) {}
myEvents: MbscCalendarEvent[] = [];
isEditable = false;
isLoggedIn = false;
isLoading = false;
calendarIds: string[] = [];
myCalendars: any = [];
startDate!: Date;
endDate!: Date;
debounce: any;
calendarData: any = {};
primaryCalendarId!: string;
calendarOptions: MbscEventcalendarOptions = {
view: {
calendar: { labels: true },
},
extendDefaultEvent: () => ({
color: this.calendarData[this.primaryCalendarId].color,
}),
onPageLoading: (args: any) => {
this.startDate = args.viewStart;
this.endDate = args.viewEnd;
clearTimeout(this.debounce);
this.debounce = setTimeout(() => {
if (outlookCalendarSync.isSignedIn()) {
this.isLoading = true;
outlookCalendarSync
.getEvents(this.calendarIds, this.startDate, this.endDate)
.then((resp: any) => {
this.zone.run(() => {
this.myEvents = resp;
this.isLoading = false;
});
})
.catch((error: any) => {
this.onError(error);
});
}
}, 200);
},
onEventCreate: (args: any) => {
if (outlookCalendarSync.isSignedIn()) {
const event = args.event;
outlookCalendarSync
.addEvent(this.primaryCalendarId, event)
.then((resp: any) => {
this.zone.run(() => {
resp.color = event.color;
this.myEvents = [...this.myEvents.filter((item) => item.id !== event.id), resp];
});
this.notify.toast({
message: 'Event created in "' + this.calendarData[this.primaryCalendarId].name + '" calendar',
});
})
.catch((error: any) => {
this.zone.run(() => {
this.myEvents = this.myEvents.filter((item) => item.id !== event.id);
this.onError(error);
});
});
}
},
onEventUpdate: (args) => {
if (outlookCalendarSync.isSignedIn()) {
this.notify
.confirm({
title: 'Are you sure you want to update this event?',
message: 'This action will affect your outlook Calendar event.',
okText: 'Update',
})
.then((result) => {
const event = args.event;
if (result) {
const calendarId = event['outlookCalendarId'];
outlookCalendarSync
.updateEvent(calendarId, event)
.then(() => {
this.notify.toast({
message: 'Event updated on "' + this.calendarData[calendarId].name + '" calendar',
});
})
.catch(() => {
this.zone.run(() => {
this.myEvents = [...this.myEvents.filter((item) => item.id !== event.id), args.oldEvent!];
});
});
} else {
this.myEvents = [...this.myEvents.filter((item) => item.id !== event.id), args.oldEvent!];
}
});
}
},
onEventDelete: (args) => {
if (outlookCalendarSync.isSignedIn()) {
this.notify
.confirm({
title: 'Are you sure you want to delete this event?',
message: 'This action will remove the event from your outlook Calendar as well.',
okText: 'Delete',
})
.then((result) => {
if (result) {
const event = args.event;
const calendarId = event['outlookCalendarId'];
outlookCalendarSync
.deleteEvent(calendarId + 'a', event)
.then(() => {
this.zone.run(() => {
this.myEvents = this.myEvents.filter((item) => item.id !== event.id);
});
this.notify.toast({
message: 'Event deleted from "' + this.calendarData[calendarId].name + '" calendar',
});
})
.catch((error: any) => {
this.onError(error);
});
}
});
}
return false;
},
};
ngOnInit(): void {
outlookCalendarSync.init({
clientId: '<YOUR_OUTLOOK_CLIENT_ID>',
redirectUri: '<YOUR_OUTLOOK_REDIRECT_URI>',
onSignedIn: () => {
this.isLoggedIn = true;
outlookCalendarSync
.getCalendars()
.then((calendars: any) => {
calendars.sort((a: { isDefaultCalendar: boolean }) => (a.isDefaultCalendar ? -1 : 1));
this.myCalendars = calendars;
this.primaryCalendarId = calendars[0].id;
this.calendarIds = [...this.calendarIds, this.primaryCalendarId];
for (const c of calendars) {
this.calendarData[c.id] = { name: c.name, color: c.hexColor, checked: false };
}
this.isLoading = true;
outlookCalendarSync
.getEvents([this.primaryCalendarId], this.startDate, this.endDate)
.then((resp: any) => {
this.zone.run(() => {
this.myEvents = resp;
this.calendarData[this.primaryCalendarId].checked = true;
this.isLoading = false;
});
})
.catch((error: any) => {
this.onError(error);
});
})
.catch((error: any) => {
this.onError(error);
});
},
onSignedOut: () => {
this.isLoggedIn = false;
this.myCalendars = [];
this.calendarIds = [];
this.calendarData = {};
this.myEvents = [];
},
});
}
onError(resp: any): void {
this.notify.toast({
message: resp.message,
});
}
changeEditable(ev: any): void {
this.isEditable = ev.target.checked;
}
toggleCalendars(ev: any, calendarId: string): void {
const checked = ev.target.checked;
this.calendarData[calendarId].checked = checked;
if (checked) {
this.calendarIds = [...this.calendarIds, calendarId];
this.isLoading = true;
outlookCalendarSync
.getEvents([calendarId], this.startDate, this.endDate)
.then((resp: any) => {
this.zone.run(() => {
this.myEvents = [...this.myEvents, ...resp];
this.isLoading = false;
});
})
.catch((error: any) => {
this.onError(error);
});
} else {
this.calendarIds = this.calendarIds.filter((id) => id !== calendarId);
this.myEvents = this.myEvents.filter((event) => event['outlookCalendarId'] !== calendarId);
}
}
logOut(): void {
outlookCalendarSync.signOut().catch((error: any) => {
this.onError(error);
});
}
logIn(): void {
if (!outlookCalendarSync.isSignedIn()) {
outlookCalendarSync.signIn().catch((error: any) => {
this.onError(error);
});
}
}
}
<mbsc-page class="md-sync-events-outlook-cont" [ngClass]="{'md-loading-events': isLoading}">
<div class="md-sync-events-outlook-menu">
<ng-container *ngIf="!isLoggedIn">
<div class="mbsc-form-group-inset mbsc-align-center">
<p class="mbsc-italic mbsc-txt-muted">Log into your Outlook account to view and edit your Outlook Calendar events</p>
<mbsc-button class="md-sync-events-outlook-button mbsc-button-block" (click)="logIn()">Sync my outlook calendars </mbsc-button>
</div>
</ng-container>
<ng-container *ngIf="isLoggedIn">
<div class="mbsc-form-group-inset mbsc-align-center">
<p class="mbsc-italic mbsc-txt-muted">
Editing events sync back to your calendar when enabled. You'll be asked for confirmation on every action.
</p>
</div>
<div class="mbsc-form-group-inset">
<mbsc-switch label="Enable editing" [(ngModel)]="isEditable" (change)="changeEditable($event)"></mbsc-switch>
</div>
<div class="mbsc-form-group-inset md-sync-events-outlook-inset">
<ng-container *ngFor="let cal of myCalendars;">
<mbsc-switch
label="{{cal.name}}"
[(ngModel)]="calendarData[cal.id].checked"
(change)="toggleCalendars($event, cal.id)"
></mbsc-switch>
</ng-container>
</div>
<div class="mbsc-form-group-inset">
<mbsc-button class="md-sync-events-outlook-button mbsc-button-block" (click)="logOut()">Log out of my account </mbsc-button>
</div>
</ng-container>
</div>
<div class="md-sync-events-outlook-calendar" [ngClass]="{'md-loading-events': isLoading}">
<div class="md-sync-events-overlay"></div>
<mbsc-eventcalendar
[options]="calendarOptions"
[data]="myEvents"
[exclusiveEndDates]="true"
[clickToCreate]="isEditable"
[dragToCreate]="isEditable"
[dragToMove]="isEditable"
[dragToResize]="isEditable"
[headerTemplate]="customTemplate"
>
<ng-template #customTemplate>
<mbsc-calendar-nav></mbsc-calendar-nav>
<div class="md-spinner">
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
<div class="md-spinner-blade"></div>
</div>
<div class="md-outlook-calendar-header">
<mbsc-calendar-prev></mbsc-calendar-prev>
<mbsc-calendar-today></mbsc-calendar-today>
<mbsc-calendar-next></mbsc-calendar-next>
</div>
</ng-template>
</mbsc-eventcalendar>
</div>
</mbsc-page>
.md-sync-events-outlook-cont.mbsc-page {
display: flex;
height: 600px;
}
.md-sync-events-outlook-menu {
flex: 0 0 350px;
height: 100%;
overflow: auto;
}
.md-sync-events-outlook-calendar {
flex: 1 1 auto;
border-left: 1px solid #ccc;
}
.md-outlook-calendar-header {
flex: 1 0 auto;
display: flex;
justify-content: flex-end;
}
.md-sync-events-outlook-button.mbsc-button {
text-transform: capitalize;
}
.md-sync-events-outlook-inset {
margin-bottom: 0;
}
@media (max-width: 800px) {
.md-sync-events-outlook-cont.mbsc-page {
display: block;
height: auto;
}
}
/* loading spinner and overlay */
.md-loading-events .md-sync-events-overlay {
position: absolute;
z-index: 2;
top: 0;
right: 0;
bottom: 0;
left: 0;
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
.md-spinner {
visibility: hidden;
position: relative;
width: 20px;
height: 20px;
}
.md-loading-events .md-spinner {
visibility: visible;
}
.md-spinner .md-spinner-blade {
position: absolute;
left: 44.5%;
top: 37%;
width: 10%;
height: 25%;
border-radius: 50%/20%;
background-color: #8c8c8c;
-webkit-animation: md-spinner-fade 1s linear infinite;
animation: md-spinner-fade 1s linear infinite;
-webkit-animation-play-state: paused;
animation-play-state: paused;
}
.md-spinner .md-spinner-blade:nth-child(1) {
-webkit-animation-delay: -1.66667s;
animation-delay: -1.66667s;
-webkit-transform: rotate(30deg) translate(0, -150%);
transform: rotate(30deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(2) {
-webkit-animation-delay: -1.58333s;
animation-delay: -1.58333s;
-webkit-transform: rotate(60deg) translate(0, -150%);
transform: rotate(60deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(3) {
-webkit-animation-delay: -1.5s;
animation-delay: -1.5s;
-webkit-transform: rotate(90deg) translate(0, -150%);
transform: rotate(90deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(4) {
-webkit-animation-delay: -1.41667s;
animation-delay: -1.41667s;
-webkit-transform: rotate(120deg) translate(0, -150%);
transform: rotate(120deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(5) {
-webkit-animation-delay: -1.33333s;
animation-delay: -1.33333s;
-webkit-transform: rotate(150deg) translate(0, -150%);
transform: rotate(150deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(6) {
-webkit-animation-delay: -1.25s;
animation-delay: -1.25s;
-webkit-transform: rotate(180deg) translate(0, -150%);
transform: rotate(180deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(7) {
-webkit-animation-delay: -1.16667s;
animation-delay: -1.16667s;
-webkit-transform: rotate(210deg) translate(0, -150%);
transform: rotate(210deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(8) {
-webkit-animation-delay: -1.08333s;
animation-delay: -1.08333s;
-webkit-transform: rotate(240deg) translate(0, -150%);
transform: rotate(240deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(9) {
-webkit-animation-delay: -1s;
animation-delay: -1s;
-webkit-transform: rotate(270deg) translate(0, -150%);
transform: rotate(270deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(10) {
-webkit-animation-delay: -0.91667s;
animation-delay: -0.91667s;
-webkit-transform: rotate(300deg) translate(0, -150%);
transform: rotate(300deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(11) {
-webkit-animation-delay: -0.83333s;
animation-delay: -0.83333s;
-webkit-transform: rotate(330deg) translate(0, -150%);
transform: rotate(330deg) translate(0, -150%);
}
.md-spinner .md-spinner-blade:nth-child(12) {
-webkit-animation-delay: -0.75s;
animation-delay: -0.75s;
-webkit-transform: rotate(360deg) translate(0, -150%);
transform: rotate(360deg) translate(0, -150%);
}
.md-loading-events .md-spinner-blade {
-webkit-animation-play-state: running;
animation-play-state: running;
}
@-webkit-keyframes md-spinner-fade {
0% {
opacity: 0.85;
}
50% {
opacity: 0.25;
}
100% {
opacity: 0.25;
}
}
@keyframes md-spinner-fade {
0% {
opacity: 0.85;
}
50% {
opacity: 0.25;
}
100% {
opacity: 0.25;
}
}