===========================================================================================
You can now use this in Ionic, Cordova, Browser based process (where CORS is disabled), Outlook Add-in or Mail apps. see ews-js-api-browser
for more detail
0.9.0
===========================================================================================
EWS managed API for TypeScript/JavaScript - code ported from OfficeDev/ews-managed-api. availbale for nodejs, browser and mobile devices (cordova).
Pluggable XHRApi adapter to replace client (browser) based XHR call with server brokered call (example coming soon). Example Ruby on rails, PHP or any server side framework where c# or nodejs is not available
Works with Office 365/Exchange Online and on-premises Exchange (2007 - 2016)
use SSL for basic authentication
NTLM and Cookies Authentication works with nodejs only
All http call is wrapped in promise using default BlueBird promise. You can also interchange compatible promise api.
Code sample from EWS Managed API 2.1. should work with little modificaion to Promise format
You can also leverage new async/await feature of nodejs (>7.0.6) or in TypeScript transpilation with es5/es6 code.
Api document generated using TypeDoc and is hosted at ews-javascript-api.github.io/api. ** outdated Check Wiki for more details
keep track of what is coming in backlog, keep eye on milestones when I start working on it
GroupMember
and GroupMemberCollection
classes are implementedExtendedPropertyCollection
code updated, was not letting changes in Email or Phone number in contact object.SimpleServiceRequestBase
code improved, should prevent unhandled rejection in case of response status 200 and local parsing errors.ExtendedPropertyDefinition
propertyset in output xml.ServiceResponseCollection.GetEnumerator()
is now returning Responses
array rather than throwing error.DeleteAttachmentRequest
, it was preventing any request to DeleteAttachment in EWS.Contact.FileAsMapping
would not work and cause unhandled Excepttionimport {....., ConfigurationApi, .......} from 'ews-javascript-api';
// use this before instantiating ExchangeService
ConfigurationApi.SetXHROptions({rejectUnauthorized : false});
for more details on which all options supported, see https://github.com/gautamsi/ews-javascript-api/blob/6618c29c08a5ad087abe9636c3128bef9837d4ae/src/js/XHRDefault.ts#L159 and https://github.com/andris9/fetch
ExchangeService.GetServerTimeZones()
can be used to get Windows TimeZone information from serverExchangeService
instance see issue link for how toOnChange
tracking is implemented, various array like fields (EmailSddresses, PhoneNumbers etc.) can now be updated properly. see #137DateTime
object is now more compatible with c# counterpart, see issue for more details on which all property and functions are availableOnResponseHeader
delegate on StreamingSubscriptionConnection
object. helps in detemining when connection is establishedCaveat: all binary data and XML data should be converted to base64 string, this library assumes all base64 strings where binary data or c# byte[] is used.
this
lexical scope in delegate calls when called by xhr promise.ServiceRequestUnauthorizedException
class to detect "Unauthorized" exception in case of 401 status code in http call. SoapFaultDetails.Exception
can be checked for this class type in case of 401 exception in xhr call.GetUserRetentionPolicyTags
is ready to use see MSDN: GetUserRetentionPolicyTags operationMailbox
object cause error when used withuot reoutingType
parameter, which should is "SMTP"/null
by default. Constructor overloads have now implemented.AutodiscoverService.GetUserSettings
silently crashs when one of the user is not found in ExchangeGetInboxRules
and UpdateInboxRules
methods on ExchangeService now availbale see MSDN: How to: Manage Inbox rules by using EWS in ExchangeSyncFolderItems
and SyncFolderHierarchy
ExchangeService now availbale see MSDN for exampleSetTeamMailbox
and UnpinTeamMailbox
ExchangeService methods now availbale. (SetTeamMailbox
does not work with Office 365, Access Denied error, on-prem test is pending) See official MSDN reference for detail ExchangeService.UnpinTeamMailbox methodGetRooms
and GetRoomLists
ExchangeService methods now availbale. See official MSDN reference for detail ExchangeService.GetRooms method and ExchangeService.GetRoomLists methodConvertId
and ConvertIds
ExchangeService methods now availbale, see MSDN detail at EWS Identifiers in ExchangeGetClientAccessToken
ExchangeService method now availbale, used with "Mail App" management, App management (#41) coming laterImpersonatedUserId
bug #34SearchFilter
code update. See official MSDN link for examples How to: Use search filters with EWS in ExchangeExtendedPropertyDefinition
works, see #23 for an example.Grouping
class updated, it can be applied on FindItems
AccountLockout
detection in failed conenction. Does not work with Office 365Contact
object related code udpate, fix code errorsSoapFaultDetails
updated for improved error handling, most EWS operation not return instance of SoapFaultDetails
in case of any failure, it contains Exception
property with information of failures oe exception in operation.FindItems
improvements
new Appointment()
Appointment.Save()
Appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy)
Appointment
GetUserOofSettings
and SetUserOofSettings
on ExchangeService is ready to be used.[sudo] npm install ews-javascript-api
//classic Javascript style
var ews = require('ews-javascript-api');
var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
//ES6 TypeScript style
import {ExchangeService, AutodiscoverService, Folder, Item, ExchangeVersion} from "ews-javascript-api";
var exch = new ExchangeService(ExchangeVersion.Exchange2013);
//import ews module
var ews = require('ews-javascript-api');
//create AutodiscoverService object
var autod = new ews.AutodiscoverService(new ews.Uri("https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc"), ews.ExchangeVersion.Exchange2010);
//you can omit url and it will autodiscover the url, version helps throw error on client side for unsupported operations.example - //var autod = new ews.AutodiscoverService(ews.ExchangeVersion.Exchange2010);
//set credential for service
autod.Credentials = new ews.ExchangeCredentials("userName", "password");
//create array to include list of desired settings
var settings = [
ews.UserSettingName.InternalEwsUrl,
ews.UserSettingName.ExternalEwsUrl,
ews.UserSettingName.UserDisplayName,
ews.UserSettingName.UserDN,
ews.UserSettingName.EwsPartnerUrl,
ews.UserSettingName.DocumentSharingLocations,
ews.UserSettingName.MailboxDN,
ews.UserSettingName.ActiveDirectoryServer,
ews.UserSettingName.CasVersion,
ews.UserSettingName.ExternalWebClientUrls,
ews.UserSettingName.ExternalImap4Connections,
ews.UserSettingName.AlternateMailboxes
];
//get the setting
autod.GetUserSettings(["email1@domain.com", "email2@domain.com"], settings)
.then(function (response) {
//do what you want with user settings
var tabcount = 0;
var tabs = function () { return ews.StringHelper.Repeat("\t", tabcount); };
console.log(autod.Url.ToString());
//uncoment next line to see full response from autodiscover, you will need to add var util = require('util');
//console.log(util.inspect(response, { showHidden: false, depth: null, colors: true }));
for (var _i = 0, _a = response.Responses; _i < _a.length; _i++) {
var resp = _a[_i];
console.log(ews.StringHelper.Format("{0}settings for email: {1}", tabs(), resp.SmtpAddress));
tabcount++;
for (var setting in resp.Settings) {
console.log(ews.StringHelper.Format("{0}{1} = {2}", tabs(), ews.UserSettingName[setting], resp.Settings[setting]));
}
tabcount--;
}
}, function (e) {
//log errors or do something with errors
});
Example of user availability
var ews = require('ews-javascript-api');
//create ExchangeService object
var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
exch.Credentials = new ews.ExchangeCredentials("userName", "password");
//set ews endpoint url to use
exch.Url = new ews.Uri("https://outlook.office365.com/Ews/Exchange.asmx"); // you can also use exch.AutodiscoverUrl
var attendee =[ new ews.AttendeeInfo("email1@domain.com"), new ews.AttendeeInfo("email2@domain.com")];
//create timewindow object o request avaiability suggestions for next 48 hours, DateTime and TimeSpan object is created to mimic portion of .net datetime/timespan object using momentjs
var timeWindow = new ews.TimeWindow(ews.DateTime.Now, ews.DateTime.Now.AddDays(2));
exch.GetUserAvailability(attendee, timeWindow, ews.AvailabilityData.FreeBusyAndSuggestions)
.then(function (availabilityResponse) {
//do what you want with user availability
}, function (errors) {
//log errors or do something with errors
});
Review Core/ExchangeService methods in api document, Any method not marked private oe internal (internal marker is in description of method) is posted and can be used, open issue if it doe snot work
ArchiveItems
AutodiscoverUrl
BindToGroupItems
BindToItems
ConvertId
ConvertIds
CopyItems
CreateItems
DeleteItems
ExpandGroup
FindAppointments
FindFolders
FindItems
GetAttachments
GetClientAccessToken
GetPasswordExpirationDate
GetRoomLists
GetRooms
GetUserAvailability
GetUserOofSettings
GetUserOofSettings
LoadPropertiesForItems
MarkAsJunk
MoveItems
ResolveName
SetTeamMailbox
SetUserOofSettings SetUserOofSettings
SubscribeToPullNotifications
SubscribeToStreamingNotifications
SubscribeToStreamingNotificationsOnAllFolders
SyncFolderHierarchy
SyncFolderItems
UnpinTeamMailbox
UpdateItems
GetInboxRules
UpdateInboxRules
AddDelegates
GetDelegates
RemoveDelegates
UpdateDelegates
GetUserRetentionPolicyTags
FindConversation
FindGroupConversation
GetConversationItems
GetGroupConversationItems
EnableAlwaysCategorizeItemsInConversations
DisableAlwaysCategorizeItemsInConversations
EnableAlwaysDeleteItemsInConversations
DisableAlwaysDeleteItemsInConversations
EnableAlwaysMoveItemsInConversations
DisableAlwaysMoveItemsInConversations
MoveItemsInConversations
CopyItemsInConversations
DeleteItemsInConversations
SetReadStateForItemsInConversations
SetRetentionPolicyForItemsInConversations
SetFlagStatusForItemsInConversations
GetAppManifests
GetAppMarketplaceUrl
DisableApp
InstallApp
UninstallApp
GetDiscoverySearchConfiguration
GetHoldOnMailboxes
GetNonIndexableItemDetails
GetNonIndexableItemStatistics
GetSearchableMailboxes
SearchMailboxes
SetHoldOnMailboxes
BindToFolder
CopyFolder
CreateFolder
DeleteFolder
EmptyFolder
FindFolders
FindItems
Load
LoadPropertiesForFolder
MarkAllItemsAsRead
MarkAllItemsAsUnread
RemoveExtendedProperty
SetExtendedProperty
MoveFolder
Save
UpdateFolder
ArchiveItem
BindToItem
CopyItem[s]
CreateItem
DeleteItem[s]
FindAppointments
FindItems
LoadPropertiesForItems
MarkAsJunk
MoveItem
SendItem
Save
UpdateItem[s]
RemoveExtendedProperty
SetExtendedProperty
AcceptTentatively [Appointment]
AcceptTentatively [Appointment]
Decline [Appointment]
AMD module for require.js to be included in build system, bower module and related documentation will be published.
in progress....
Licensed under MIT
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。