Skip to content

Commit eb8fe60

Browse files
committed
feat: Add support for retrieving emails with singleValueExtendedProperties
1 parent e129c9d commit eb8fe60

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

docs/v3/msgraph/emails.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ To view an email call **->find($id)** followed by the id of the email.
134134
MsGraph::emails()->find($id);
135135
```
136136

137+
Retrieve the emails using singleValueExtendedProperties.
138+
139+
```php
140+
MsGraph::emails()->get([
141+
'\$filter' => 'singleValueExtendedProperties/Any(ep: ep/id eq \'String {00020329-0000-0000-C000-000000000046} Name CustomProperty\' and ep/value eq \'CustomValue\')'
142+
]);
143+
```
144+
137145
## Send Email
138146

139147
To send an email the format is different to normal calls. The format is to call multiple methods to set the email properties.
@@ -172,6 +180,22 @@ MsGraph::emails()
172180
->send()
173181
```
174182

183+
singleValueExtendedProperties() can be used to add custom properties to the email.
184+
185+
```php
186+
MsGraph::emails()
187+
188+
->subject('the subject')
189+
->body('the content')
190+
->singleValueExtendedProperties([
191+
[
192+
"id" => "String {00020329-0000-0000-C000-000000000046} Name CustomProperty",
193+
"value" => "CustomValue"
194+
]
195+
])
196+
->send()
197+
```
198+
175199
## Forward Email
176200

177201
To forward to an email call **->forward()** and use **->comment()** instead of **->body()**.
@@ -205,7 +229,3 @@ To delete an email call **->delete($id)** followed by the id of the email.
205229
```php
206230
MsGraph::emails()->delete($id);
207231
```
208-
209-
210-
211-

src/Resources/Emails.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Emails extends MsGraph
2727

2828
private array $attachments = [];
2929

30+
private array $singleValueExtendedProperties = [];
31+
3032
public function id(string $id): static
3133
{
3234
$this->id = $id;
@@ -246,6 +248,7 @@ protected function prepareEmail(): array
246248
$cc = $this->cc;
247249
$bcc = $this->bcc;
248250
$attachments = $this->attachments;
251+
$singleValueExtendedProperties = $this->singleValueExtendedProperties;
249252

250253
$toArray = [];
251254
foreach ($to as $email) {
@@ -274,6 +277,14 @@ protected function prepareEmail(): array
274277
];
275278
}
276279

280+
$singleValueExtendedPropertiesarray = [];
281+
foreach ($singleValueExtendedProperties as $value) {
282+
$singleValueExtendedPropertiesarray[] = [
283+
'id' => $value['id'],
284+
'value' => $value['value'],
285+
];
286+
}
287+
277288
$envelope = [];
278289
if ($subject !== '') {
279290
$envelope['message']['subject'] = $subject;

0 commit comments

Comments
 (0)