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
32 changes: 32 additions & 0 deletions docs/v3/msgraph/emails.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ To view an email call **->find($id)** followed by the id of the email.
MsGraph::emails()->find($id);
```

> From version v4.0.6, mark email as read when viewing it.

```php
MsGraph::emails()->find($id, bool $markAsRead = false);
```

Retrieve the emails using singleValueExtendedProperties.

```php
Expand All @@ -144,6 +150,32 @@ MsGraph::emails()->get([
]);
```

## Get Email Attachments

Get email attachments
```php
MsGraph::emails()->findAttachment($id);
```

## Get Email Attachment

Get email attachment by its id
```php
MsGraph::emails()->findAttachment($id, $attachmentId);
```

## Mark email as read

```php
MsGraph::emails()->markAsRead($id);
```

## Mark email as unread

```php
MsGraph::emails()->markAsUnread($id);
```

## Send Email

To send an email the format is different to normal calls. The format is to call multiple methods to set the email properties.
Expand Down
21 changes: 20 additions & 1 deletion src/Resources/Emails/Emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,12 @@ public function get(string $folderIdOrName = 'Inbox', array $params = []): array
}
}

public function find(string $id): array
public function find(string $id, bool $markAsRead = false): array
{
if ($markAsRead) {
self::markAsRead($id);
}

return MsGraph::get('me/messages/'.$id);
}

Expand All @@ -161,6 +165,11 @@ public function findAttachments(string $id): array
return MsGraph::get('me/messages/'.$id.'/attachments');
}

public function findAttachment(string $id, string $attachmentId): array
{
return MsGraph::get('me/messages/'.$id.'/attachments/'.$attachmentId);
}

public function findInlineAttachments(array $email): array
{
$attachments = self::findAttachments($email['id']);
Expand Down Expand Up @@ -192,6 +201,16 @@ function (array $m) use ($attachments) {
return $email;
}

public function markAsRead(string $id): void
{
MsGraph::patch('me/messages/'.$id, ['isRead' => true]);
}

public function markAsUnread(string $id): void
{
MsGraph::patch('me/messages/'.$id, ['isRead' => false]);
}

/**
* @throws Exception
*/
Expand Down