0.3.0 • Published 2 years ago

ews-simple v0.3.0

Weekly downloads
14
License
ISC
Repository
github
Last release
2 years ago

ews-simple

Introduction

This package is build on top of ews-javascript-api and makes performing EWS operations easier.

API

ClientBuilder

This builder should allow you to configure EWS service with the specified url and auth data.

Supported methods: 1. withVersion (value: ClientVersion) - configures ews version (default value is ClientVersion.Exchange2013) 2. withUser (value: string) - configures ews user name 3. withPwd (value: string) - configures user pwd 4. withUri (value: string) - configures ews server uri 5. withToken (value: string) - configures user authorization token

Example

const service = new ClientBuilder()
  .withUser(`<EWS username>`)
  .withPwd(`<EWS user pwd>`)
  .build();

FindItemsResultBuilder

This builder should allow you to return search results using the specified input folder and query string.

Supported methods: 1. withService (value: ews.ExchangeService) - allow set ews service to be linked to 2. withFolder (value: FolderEnum) - allow to set ews folder to be looked into 3. withTakeN (value: number) - allow to set the amount(default 1000) of items to be returned 4. withOffset (value: number) - allow to set offset 5. withOffsetBasePoint (value: 'start' | 'end') - allow to set base point(default start) 6. withQueryString (value: string) - allow to set query string for search 7. withMarkAsRead (value: boolean) - allow to set whether to mark letter as read or not 8. withDelete (value: boolean) - allow to set whether do delete letter after read 9. withGetRaw (value: boolean) - allow to set wherther to return raw items or parse them 10. withSaveAttachments (value: boolean) - allow to set whether to download attachments or not 11. withDownloadsFolder (value: string) - allow to set downloads folder for attachments(default is downloads) 12. withRawBody (value: boolean)- allow to set whether to return raw body or parse it before return

Examples

Read (get Subject, Body and Received Date) 10 unread mails from Inbox

const items = await new FindItemsResultBuilder()
  .withService(service)
  .withFolder(FolderEnum.Inbox)
  .withQueryString('isread:false')
  .withTakeN(10)
  .execute();

Read (keep them raw) 10 read mails from Favorites

const items = await new FindItemsResultBuilder()
  .withService(service)
  .withFolder(FolderEnum.Favorites)
  .withQueryString('isread:true')
  .withGetRaw(true)
  .execute();

EmailMessageBuilder

This builder should allow you to send a email with the specified data.

  1. withService (value: ews.ExchangeService) - allow set ews service to be linked to
  2. withSubject (value: string) - allow to set message subject
  3. withBodyType (value: 'text' | 'htm;') - allow to set message body content type (default text)
  4. withBody (value: string) - allow to set message body content
  5. withTo (value: string[]) - allow to set a list of To recepients
  6. withСс (value: string[]) - allow to set a list of Сс recepients
  7. withFileAttachment (value: string) - allow to set path to file attachment

Examples

Send email
await new EmailMessageBuilder()
  .withService(service)
  .withSubject(<mail subject>)
  .withBodyType(ews.BodyType.HTML)
  .withBody(<mail body>)
  .withTo(<recepients list>)
  .execute();
Send email with file attachment
await new EmailMessageBuilder()
  .withService(service)
  .withSubject(<mail subject>)
  .withBodyType(ews.BodyType.Text)
  .withBody(<mail body>)
  .withTo(<recepients list>)
  .withFileAttachment(<file name>)
  .execute();
0.3.0

2 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago