An open API service indexing awesome lists of open source software.

https://github.com/cityssm/node-ms-graph-mail

Wrappers around the Microsoft Graph API to add response types to the Mail-related queries.
https://github.com/cityssm/node-ms-graph-mail

microsoft-exchange microsoft-graph microsoft-graph-api

Last synced: 12 days ago
JSON representation

Wrappers around the Microsoft Graph API to add response types to the Mail-related queries.

Awesome Lists containing this project

README

          

# Microsoft Graph Mail API

[![DeepSource](https://app.deepsource.com/gh/cityssm/node-ms-graph-mail.svg/?label=active+issues&show_trend=true&token=KkSuPUghHqeLWICUprgijw-o)](https://app.deepsource.com/gh/cityssm/node-ms-graph-mail/)

Wrappers around the Microsoft Graph API
to add response types to the Mail-related queries.

## Installation

```sh
npm install @cityssm/ms-graph-mail
```

## Usage

```javascript
import MsGraphMail, {
MsGraphMailMessageBuilder,
wellKnownFolderNames
} from '@cityssm/ms-graph-mail'

const api = new MsGraphMail({
tenantId: '00000000-0000-0000-0000-00000000000a',
clientId: '00000000-0000-0000-0000-00000000000b',
clientSecret: 'abcd...xyz',
targetUser: 'helpdesk@example.com'
})

const inboxMessages = await api.listMessages(wellKnownFolderNames.Inbox, {
top: 5,
select: ['id', 'subject', 'receivedDateTime', 'from', 'body'],
orderBy: ['receivedDateTime desc']
})

const messageToSend = new MsGraphMailMessageBuilder()
.withSubject('Ticket #000001')
.withBody('

Ticket Received

', 'html')
.appendToBody('

Your ticket should be worked on shortly.

', 'html')
.addToRecipient('requestor@example.com')
.build()

await api.sendMessage(messageToSend)
```

## Functions

👍 It is recommended to use this package with Typescript to get usage hints.

### Folder Functions

```typescript
async function listMailFolders(
options?: MsGraphMailApiOptions
): Promise {}

async function getMailFolderByDisplayName(
displayName: string,
options?: Pick, 'select'>
): Promise {}

async function getArchiveFolder(
options?: Pick, 'select'>
): Promise {}

async function getInboxFolder(
options?: Pick, 'select'>
): Promise {}

async function getOutboxFolder(
options?: Pick, 'select'>
): Promise {}

async function getSentItemsFolder(
options?: Pick, 'select'>
): Promise {}
```

### Message Functions

```typescript
async function listMessages(
folderIdOrWellKnownFolderName: string,
options?: MsGraphMailApiOptions
): Promise {}

async function listMessageAttachments(
messageId: string,
options?: MsGraphMailApiOptions
): Promise {}
```

### Message Move Functions

```typescript
async function archiveMessage(messageId: string): Promise {}

async function moveMessage(
messageId: string,
destinationFolderIdOrWellKnownFolderName: string
): Promise {}
```

### Message Send Functions

```typescript
async function sendMessage(
message: MsGraphMailSendableMessage
): Promise {}
```

### Message Update Functions

```typescript
async function markMessageAsRead(messageId: string): Promise {}
```

## Related Projects

[**ShiftLog**](https://github.com/cityssm/shiftLog/)

A work management system with work order recording, shift activity logging,
and timesheet tracking.