-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathfind-email.mjs
46 lines (43 loc) · 1.3 KB
/
find-email.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
export default {
key: "microsoft_outlook-find-email",
name: "Find Email",
description: "Search for an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-messages)",
version: "0.0.4",
type: "action",
props: {
microsoftOutlook,
filter: {
type: "string",
label: "Filter",
description: "Filters results. For example, `contains(subject, 'meet for lunch?')` will include messages whose subject contains ‘meet for lunch?’. [See documentation](https://learn.microsoft.com/en-us/graph/filter-query-parameter) for the full list of operations.",
optional: true,
},
maxResults: {
propDefinition: [
microsoftOutlook,
"maxResults",
],
},
},
async run({ $ }) {
const items = this.microsoftOutlook.paginate({
fn: this.microsoftOutlook.listMessages,
args: {
$,
params: {
"$filter": this.filter,
},
},
max: this.maxResults,
});
const emails = [];
for await (const item of items) {
emails.push(item);
}
$.export("$summary", `Successfully retrieved ${emails.length} message${emails.length != 1
? "s"
: ""}.`);
return emails;
},
};