Skip to content

Commit 73ec077

Browse files
include attachment in new email trigger
1 parent f1c77ab commit 73ec077

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

components/microsoft_outlook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/microsoft_outlook",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "Pipedream Microsoft Outlook Components",
55
"main": "microsoft_outlook.app.mjs",
66
"keywords": [

components/microsoft_outlook/sources/common/common-new-email.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,22 @@ export default {
5454
const draftsFolderId = this.db.get("draftsFolderId");
5555
return item.parentFolderId !== sentItemFolderId && item.parentFolderId !== draftsFolderId;
5656
},
57+
async getMessageAttachments(message) {
58+
const { value: attachments } = await this.microsoftOutlook.listAttachments({
59+
messageId: message.id,
60+
});
61+
if (!attachments?.length) {
62+
return [];
63+
}
64+
return attachments.map((attachment) => ({
65+
...attachment,
66+
messageId: message.id,
67+
messageSubject: message.subject,
68+
messageSender: message.sender,
69+
messageReceivedDateTime: message.receivedDateTime,
70+
parentFolderId: message.parentFolderId,
71+
contentBytes: undefined,
72+
}));
73+
},
5774
},
5875
};

components/microsoft_outlook/sources/new-attachment-received/new-attachment-received.mjs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "microsoft_outlook-new-attachment-received",
66
name: "New Attachment Received (Instant)",
77
description: "Emit new event when a new email containing one or more attachments arrives in a specified Microsoft Outlook folder.",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {
@@ -36,23 +36,6 @@ export default {
3636
}
3737
return attachments;
3838
},
39-
async getMessageAttachments(message) {
40-
const { value: attachments } = await this.microsoftOutlook.listAttachments({
41-
messageId: message.id,
42-
});
43-
if (!attachments?.length) {
44-
return [];
45-
}
46-
return attachments.map((attachment) => ({
47-
...attachment,
48-
messageId: message.id,
49-
messageSubject: message.subject,
50-
messageSender: message.sender,
51-
messageReceivedDateTime: message.receivedDateTime,
52-
parentFolderId: message.parentFolderId,
53-
contentBytes: undefined,
54-
}));
55-
},
5639
emitEvent(item) {
5740
if (this.isRelevant(item)) {
5841
this.$emit(item, this.generateMeta(item));

components/microsoft_outlook/sources/new-email/new-email.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "microsoft_outlook-new-email",
88
name: "New Email Event (Instant)",
99
description: "Emit new event when an email is received in specified folders.",
10-
version: "0.0.19",
10+
version: "0.1.0",
1111
type: "source",
1212
dedupe: "unique",
1313
methods: {
@@ -66,6 +66,10 @@ export default {
6666
resource: folder,
6767
messageId: resourceId,
6868
});
69+
if (item.hasAttachments) {
70+
const attachments = await this.getMessageAttachments(item);
71+
item.attachments = attachments;
72+
}
6973
this.emitEvent(item);
7074
} catch {
7175
console.log(`Could not fetch message with ID: ${resourceId}`);

0 commit comments

Comments
 (0)