AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(microsoft-outlook): let agents read, send and organise mail (#15696)
Odai Ahmad6db05a14a54c
diff --git a/packages/pieces/community/microsoft-outlook/package.json b/packages/pieces/community/microsoft-outlook/package.jsonindex 86e030e2bd8..03f46098690 100644--- a/packages/pieces/community/microsoft-outlook/package.json+++ b/packages/pieces/community/microsoft-outlook/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-microsoft-outlook",- "version": "0.6.0",+ "version": "0.6.1","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","dependencies": {@@ -13,11 +13,13 @@"@activepieces/core-utils": "workspace:*"},"devDependencies": {- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"},"scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"}}diff --git a/packages/pieces/community/microsoft-outlook/src/i18n/translation.json b/packages/pieces/community/microsoft-outlook/src/i18n/translation.jsonindex 77634267f60..68e01db4119 100644--- a/packages/pieces/community/microsoft-outlook/src/i18n/translation.json+++ b/packages/pieces/community/microsoft-outlook/src/i18n/translation.json@@ -24,6 +24,50 @@"Send Draft Email": "Send Draft Email","Forward Email": "Forward Email","Find Email": "Find Email",+ "List Messages": "List Messages",+ "Get Message": "Get Message",+ "Search Messages": "Search Messages",+ "Get Message MIME Content": "Get Message MIME Content",+ "List Message Changes (Delta)": "List Message Changes (Delta)",+ "Create Draft": "Create Draft",+ "Send Draft": "Send Draft",+ "Reply to Message": "Reply to Message",+ "Reply All to Message": "Reply All to Message",+ "Forward Message": "Forward Message",+ "Create Reply Draft": "Create Reply Draft",+ "Create Reply-All Draft": "Create Reply-All Draft",+ "Create Forward Draft": "Create Forward Draft",+ "Update Message": "Update Message",+ "Mark Message Read / Unread": "Mark Message Read / Unread",+ "Move Message": "Move Message",+ "Copy Message": "Copy Message",+ "Delete Message (to Deleted Items)": "Delete Message (to Deleted Items)",+ "Permanently Delete Message": "Permanently Delete Message",+ "Batch Move Messages": "Batch Move Messages",+ "Batch Update Messages": "Batch Update Messages",+ "Add Categories to Message": "Add Categories to Message",+ "Remove Categories from Message": "Remove Categories from Message",+ "List Message Attachments": "List Message Attachments",+ "Get Message Attachment": "Get Message Attachment",+ "Download Message Attachment": "Download Message Attachment",+ "Add Attachment to Draft": "Add Attachment to Draft",+ "Delete Message Attachment": "Delete Message Attachment",+ "List Mail Folders": "List Mail Folders",+ "List Child Mail Folders": "List Child Mail Folders",+ "Get Mail Folder": "Get Mail Folder",+ "Create Mail Folder": "Create Mail Folder",+ "Rename Mail Folder": "Rename Mail Folder",+ "Delete Mail Folder": "Delete Mail Folder",+ "Copy Mail Folder": "Copy Mail Folder",+ "Move Mail Folder": "Move Mail Folder",+ "List Folder Changes (Delta)": "List Folder Changes (Delta)",+ "List Focused Inbox Overrides": "List Focused Inbox Overrides",+ "Create Focused Inbox Override": "Create Focused Inbox Override",+ "Update Focused Inbox Override": "Update Focused Inbox Override",+ "Delete Focused Inbox Override": "Delete Focused Inbox Override",+ "Get Mail Tips": "Get Mail Tips",+ "Get My Profile": "Get My Profile",+ "Get Supported Time Zones": "Get Supported Time Zones","Custom API Call": "Custom API Call","Sends an email using Microsoft Outlook.": "Sends an email using Microsoft Outlook.","Download attachments from a specific email message.": "Download attachments from a specific email message.",@@ -36,6 +80,51 @@"Sends a draft email message.": "Sends a draft email message.","Forwards an email message.": "Forwards an email message.","Searches for emails using full-text search.": "Searches for emails using full-text search.",+ "Lists messages from the mailbox or a single mail folder.": "Lists messages from the mailbox or a single mail folder.",+ "Retrieves a single message by its ID.": "Retrieves a single message by its ID.",+ "Searches messages with a full-text query.": "Searches messages with a full-text query.",+ "Downloads the raw MIME (RFC-822) content of a message.": "Downloads the raw MIME (RFC-822) content of a message.",+ "Tracks created, updated and deleted messages in a folder.": "Tracks created, updated and deleted messages in a folder.",+ "Composes and sends a new email.": "Composes and sends a new email.",+ "Creates an unsent draft message.": "Creates an unsent draft message.",+ "Sends an existing draft message.": "Sends an existing draft message.",+ "Replies to the sender of a message.": "Replies to the sender of a message.",+ "Replies to the sender and all recipients of a message.": "Replies to the sender and all recipients of a message.",+ "Forwards a message to new recipients.": "Forwards a message to new recipients.",+ "Creates an unsent reply draft for a message.": "Creates an unsent reply draft for a message.",+ "Creates an unsent reply-all draft for a message.": "Creates an unsent reply-all draft for a message.",+ "Creates an unsent forward draft for a message.": "Creates an unsent forward draft for a message.",+ "Updates the writable properties of a message.": "Updates the writable properties of a message.",+ "Marks a message as read or unread.": "Marks a message as read or unread.",+ "Moves a message to another mail folder.": "Moves a message to another mail folder.",+ "Copies a message into another mail folder.": "Copies a message into another mail folder.",+ "Moves a message to the Deleted Items folder.": "Moves a message to the Deleted Items folder.",+ "Permanently deletes a message so it cannot be recovered.": "Permanently deletes a message so it cannot be recovered.",+ "Moves several messages to one folder in a single batched call.": "Moves several messages to one folder in a single batched call.",+ "Applies the same property changes to several messages at once.": "Applies the same property changes to several messages at once.",+ "Adds categories (labels) to a message.": "Adds categories (labels) to a message.",+ "Removes categories (labels) from a message.": "Removes categories (labels) from a message.",+ "Lists the attachments of a message without downloading them.": "Lists the attachments of a message without downloading them.",+ "Reads the metadata of one attachment.": "Reads the metadata of one attachment.",+ "Downloads one file attachment of a message.": "Downloads one file attachment of a message.",+ "Attaches a file to a draft message.": "Attaches a file to a draft message.",+ "Removes an attachment from a message.": "Removes an attachment from a message.",+ "Lists the top-level mail folders of the mailbox.": "Lists the top-level mail folders of the mailbox.",+ "Lists the sub-folders of one mail folder.": "Lists the sub-folders of one mail folder.",+ "Reads one mail folder by ID or well-known name.": "Reads one mail folder by ID or well-known name.",+ "Creates a mail folder, or returns the existing one with the same name.": "Creates a mail folder, or returns the existing one with the same name.",+ "Renames a mail folder.": "Renames a mail folder.",+ "Deletes a mail folder and everything inside it.": "Deletes a mail folder and everything inside it.",+ "Copies a mail folder under another folder.": "Copies a mail folder under another folder.",+ "Moves a mail folder under another folder.": "Moves a mail folder under another folder.",+ "Tracks created, renamed and deleted mail folders.": "Tracks created, renamed and deleted mail folders.",+ "Lists the Focused Inbox sender overrides of the mailbox.": "Lists the Focused Inbox sender overrides of the mailbox.",+ "Forces mail from a sender into the Focused or Other tab.": "Forces mail from a sender into the Focused or Other tab.",+ "Changes the classification of a Focused Inbox override.": "Changes the classification of a Focused Inbox override.",+ "Removes a Focused Inbox sender override.": "Removes a Focused Inbox sender override.",+ "Reads pre-send mail tips for a set of recipients.": "Reads pre-send mail tips for a set of recipients.",+ "Reads the identity of the connected account.": "Reads the identity of the connected account.",+ "Lists the time zones Outlook accepts for this account.": "Lists the time zones Outlook accepts for this account.","Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint","To Email(s)": "To Email(s)","CC Email(s)": "CC Email(s)",@@ -49,7 +138,6 @@"Reply Body": "Reply Body","CC Recipients": "CC Recipients","BCC Recipients": "BCC Recipients",- "Create Draft": "Create Draft","Categories": "Categories","Categories to Remove": "Categories to Remove","To Email Address": "To Email Address",@@ -59,13 +147,38 @@"Search Query": "Search Query","Folder": "Folder","Max Results": "Max Results",+ "Folder ID": "Folder ID",+ "Filter": "Filter",+ "Skip": "Skip",+ "Delta Link": "Delta Link",+ "Draft Message ID": "Draft Message ID",+ "Reply Text": "Reply Text",+ "Additional CC Email(s)": "Additional CC Email(s)",+ "Read State": "Read State",+ "Flag State": "Flag State",+ "Importance": "Importance",+ "Categories to Add": "Categories to Add",+ "Destination Folder ID": "Destination Folder ID",+ "Confirm Permanent Deletion": "Confirm Permanent Deletion",+ "Message IDs": "Message IDs",+ "Attachment ID": "Attachment ID",+ "File": "File",+ "File Name": "File Name",+ "Parent Folder ID": "Parent Folder ID",+ "Folder Name": "Folder Name",+ "New Folder Name": "New Folder Name",+ "Sender Email Address": "Sender Email Address",+ "Classify As": "Classify As",+ "Sender Display Name": "Sender Display Name",+ "Override ID": "Override ID",+ "Recipient Email Addresses": "Recipient Email Addresses","Method": "Method","Headers": "Headers","Query Parameters": "Query Parameters","Body Type": "Body Type",- "Response is Binary ?": "Response is Binary ?",- "No Error on Failure": "No Error on Failure",- "Timeout (in seconds)": "Timeout (in seconds)",+ "Response is Binary": "Response is Binary",+ "Return Error as Output": "Return Error as Output",+ "Timeout": "Timeout","Follow redirects": "Follow redirects","The ID of the email message containing the attachment.": "The ID of the email message containing the attachment.","Select the email message to reply to.": "Select the email message to reply to.",@@ -85,20 +198,81 @@"Search terms to find emails (e.g., \"from:[email protected]\", \"subject:urgent\", \"hasAttachments:true\")": "Search terms to find emails (e.g., \"from:[email protected]\", \"subject:urgent\", \"hasAttachments:true\")","Search in a specific folder. Leave empty to search all folders.": "Search in a specific folder. Leave empty to search all folders.","Maximum number of results to return (1-1000).": "Maximum number of results to return (1-1000).",+ "Limit the listing to one folder. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Leave empty to list the whole mailbox.": "Limit the listing to one folder. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Leave empty to list the whole mailbox.",+ "Optional OData $filter expression, for example: isRead eq false, or receivedDateTime ge 2024-01-01T00:00:00Z.": "Optional OData $filter expression, for example: isRead eq false, or receivedDateTime ge 2024-01-01T00:00:00Z.",+ "Maximum number of messages to return (1-100).": "Maximum number of messages to return (1-100).",+ "Number of messages to skip before returning results, for paging.": "Number of messages to skip before returning results, for paging.",+ "Outlook message ID. Resolve one with List Messages, Search Messages or Get Message.": "Outlook message ID. Resolve one with List Messages, Search Messages or Get Message.",+ "Keywords or KQL terms to match, for example: from:[email protected], subject:urgent, hasAttachments:true.": "Keywords or KQL terms to match, for example: from:[email protected], subject:urgent, hasAttachments:true.",+ "Search inside one folder only. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Leave empty to search the whole mailbox.": "Search inside one folder only. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Leave empty to search the whole mailbox.",+ "Folder to track. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail.": "Folder to track. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail.",+ "The deltaLink returned by a previous run. Leave empty to start a new sync from the current folder state.": "The deltaLink returned by a previous run. Leave empty to start a new sync from the current folder state.",+ "Email addresses of the primary recipients.": "Email addresses of the primary recipients.",+ "Files to attach. Total message size must stay under 3 MB.": "Files to attach. Total message size must stay under 3 MB.",+ "Create the draft inside a specific folder. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Leave empty to use the Drafts folder.": "Create the draft inside a specific folder. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Leave empty to use the Drafts folder.",+ "ID of the draft to send. Obtain it from Create Draft or one of the Create ... Draft actions.": "ID of the draft to send. Obtain it from Create Draft or one of the Create ... Draft actions.",+ "Text added above the quoted original message.": "Text added above the quoted original message.",+ "Email addresses to forward the message to.": "Email addresses to forward the message to.",+ "Optional text added above the forwarded message.": "Optional text added above the forwarded message.",+ "Optional text added above the quoted original message.": "Optional text added above the quoted original message.",+ "Email addresses the draft will forward the message to.": "Email addresses the draft will forward the message to.",+ "Leave unset to keep the current read state.": "Leave unset to keep the current read state.",+ "Leave unset to keep the current flag.": "Leave unset to keep the current flag.",+ "Leave unset to keep the current importance.": "Leave unset to keep the current importance.",+ "Category names to add, merged with the categories already on the message.": "Category names to add, merged with the categories already on the message.",+ "Category names to remove from the message.": "Category names to remove from the message.",+ "Only writable while the message is still a draft.": "Only writable while the message is still a draft.",+ "Format of the new body. Ignored when no body is supplied.": "Format of the new body. Ignored when no body is supplied.",+ "Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail.": "Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail.",+ "Must be enabled. The message cannot be recovered afterwards.": "Must be enabled. The message cannot be recovered afterwards.",+ "IDs of the messages to move. Resolve them with List Messages or Search Messages.": "IDs of the messages to move. Resolve them with List Messages or Search Messages.",+ "IDs of the messages to update. Resolve them with List Messages or Search Messages.": "IDs of the messages to update. Resolve them with List Messages or Search Messages.",+ "Leave unset to keep each message current read state.": "Leave unset to keep each message current read state.",+ "Leave unset to keep each message current flag.": "Leave unset to keep each message current flag.",+ "Leave unset to keep each message current importance.": "Leave unset to keep each message current importance.",+ "Category names merged into the categories each message already has.": "Category names merged into the categories each message already has.",+ "Category names removed from each message.": "Category names removed from each message.",+ "Category names to add to the message.": "Category names to add to the message.",+ "Attachment ID from List Message Attachments. Attachment IDs are only valid inside their own message.": "Attachment ID from List Message Attachments. Attachment IDs are only valid inside their own message.",+ "ID of the draft to attach the file to. Obtain it from Create Draft.": "ID of the draft to attach the file to. Obtain it from Create Draft.",+ "File to attach. Must be smaller than 3 MB.": "File to attach. Must be smaller than 3 MB.",+ "Name shown on the attachment. Defaults to the uploaded file name.": "Name shown on the attachment. Defaults to the uploaded file name.",+ "Attachment ID from List Message Attachments.": "Attachment ID from List Message Attachments.",+ "Maximum number of folders to return (1-100).": "Maximum number of folders to return (1-100).",+ "Display name of the folder to create.": "Display name of the folder to create.",+ "Create the folder under this parent. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Leave empty to create it at the top level.": "Create the folder under this parent. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Leave empty to create it at the top level.",+ "Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Well-known system folders cannot be deleted.": "Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail. Well-known system folders cannot be deleted.",+ "Folder that will contain the copy. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail.": "Folder that will contain the copy. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail.",+ "New parent folder. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail.": "New parent folder. Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail.",+ "The deltaLink returned by a previous run. Leave empty to start a new sync from the current folder tree.": "The deltaLink returned by a previous run. Leave empty to start a new sync from the current folder tree.",+ "SMTP address of the sender the override applies to.": "SMTP address of the sender the override applies to.",+ "Optional display name stored alongside the override.": "Optional display name stored alongside the override.",+ "Override ID from List Focused Inbox Overrides.": "Override ID from List Focused Inbox Overrides.",+ "Addresses to check. Up to 100 recipients per call.": "Addresses to check. Up to 100 recipients per call.","Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",+ "Appended to the URL as ?key=value.": "Appended to the URL as ?key=value.","Enable for files like PDFs, images, etc.": "Enable for files like PDFs, images, etc.",+ "On a failed request, output the error instead of failing the step.": "On a failed request, output the error instead of failing the step.",+ "Seconds to wait for a response. Empty: up to the flow limit (10 min).": "Seconds to wait for a response. Empty: up to the flow limit (10 min).",+ "Follow 3xx redirects instead of returning them as the response.": "Follow 3xx redirects instead of returning them as the response.","HTML": "HTML","Text": "Text",+ "Mark as read": "Mark as read",+ "Mark as unread": "Mark as unread",+ "Flagged": "Flagged",+ "Not flagged": "Not flagged",+ "Complete": "Complete",+ "Low": "Low",+ "Normal": "Normal",+ "High": "High",+ "Focused": "Focused",+ "Other": "Other","GET": "GET","POST": "POST","PATCH": "PATCH","PUT": "PUT","DELETE": "DELETE","HEAD": "HEAD",- "None": "None",- "JSON": "JSON",- "Form Data": "Form Data",- "Raw": "Raw","New Email": "New Email","New Email in Folder": "New Email in Folder","New Attachment": "New Attachment",diff --git a/packages/pieces/community/microsoft-outlook/src/index.ts b/packages/pieces/community/microsoft-outlook/src/index.tsindex 7fab2aa5095..30c48cf718d 100644--- a/packages/pieces/community/microsoft-outlook/src/index.ts+++ b/packages/pieces/community/microsoft-outlook/src/index.ts@@ -17,6 +17,51 @@ import { newAttachmentTrigger } from './lib/triggers/new-attachment';import { newEmailInFolderTrigger } from './lib/triggers/new-email-in-folder';import { newEmailTrigger } from './lib/triggers/new-email';import { requestApprovalInMail } from './lib/actions/request-approval-send-email';+import { outlookAddMessageAttachmentAction } from './lib/actions/outlook-add-message-attachment';+import { outlookAddMessageCategoriesAction } from './lib/actions/outlook-add-message-categories';+import { outlookBatchMoveMessagesAction } from './lib/actions/outlook-batch-move-messages';+import { outlookBatchUpdateMessagesAction } from './lib/actions/outlook-batch-update-messages';+import { outlookCopyMailFolderAction } from './lib/actions/outlook-copy-mail-folder';+import { outlookCopyMessageAction } from './lib/actions/outlook-copy-message';+import { outlookCreateDraftAction } from './lib/actions/outlook-create-draft';+import { outlookCreateFocusedInboxOverrideAction } from './lib/actions/outlook-create-focused-inbox-override';+import { outlookCreateForwardDraftAction } from './lib/actions/outlook-create-forward-draft';+import { outlookCreateMailFolderAction } from './lib/actions/outlook-create-mail-folder';+import { outlookCreateReplyAllDraftAction } from './lib/actions/outlook-create-reply-all-draft';+import { outlookCreateReplyDraftAction } from './lib/actions/outlook-create-reply-draft';+import { outlookDeleteFocusedInboxOverrideAction } from './lib/actions/outlook-delete-focused-inbox-override';+import { outlookDeleteMailFolderAction } from './lib/actions/outlook-delete-mail-folder';+import { outlookDeleteMessageAction } from './lib/actions/outlook-delete-message';+import { outlookDeleteMessageAttachmentAction } from './lib/actions/outlook-delete-message-attachment';+import { outlookDownloadMessageAttachmentAction } from './lib/actions/outlook-download-message-attachment';+import { outlookForwardMessageAction } from './lib/actions/outlook-forward-message';+import { outlookGetMailFolderAction } from './lib/actions/outlook-get-mail-folder';+import { outlookGetMailTipsAction } from './lib/actions/outlook-get-mail-tips';+import { outlookGetMessageAction } from './lib/actions/outlook-get-message';+import { outlookGetMessageAttachmentAction } from './lib/actions/outlook-get-message-attachment';+import { outlookGetMessageMimeAction } from './lib/actions/outlook-get-message-mime';+import { outlookGetMyProfileAction } from './lib/actions/outlook-get-my-profile';+import { outlookGetSupportedTimeZonesAction } from './lib/actions/outlook-get-supported-time-zones';+import { outlookListChildMailFoldersAction } from './lib/actions/outlook-list-child-mail-folders';+import { outlookListFocusedInboxOverridesAction } from './lib/actions/outlook-list-focused-inbox-overrides';+import { outlookListMailFoldersAction } from './lib/actions/outlook-list-mail-folders';+import { outlookListMailFoldersDeltaAction } from './lib/actions/outlook-list-mail-folders-delta';+import { outlookListMessageAttachmentsAction } from './lib/actions/outlook-list-message-attachments';+import { outlookListMessagesAction } from './lib/actions/outlook-list-messages';+import { outlookListMessagesDeltaAction } from './lib/actions/outlook-list-messages-delta';+import { outlookMoveMailFolderAction } from './lib/actions/outlook-move-mail-folder';+import { outlookMoveMessageAction } from './lib/actions/outlook-move-message';+import { outlookPermanentlyDeleteMessageAction } from './lib/actions/outlook-permanently-delete-message';+import { outlookRemoveMessageCategoriesAction } from './lib/actions/outlook-remove-message-categories';+import { outlookReplyAllToMessageAction } from './lib/actions/outlook-reply-all-to-message';+import { outlookReplyToMessageAction } from './lib/actions/outlook-reply-to-message';+import { outlookSearchMessagesAction } from './lib/actions/outlook-search-messages';+import { outlookSendDraftAction } from './lib/actions/outlook-send-draft';+import { outlookSendEmailAction } from './lib/actions/outlook-send-email';+import { outlookSetMessageReadStatusAction } from './lib/actions/outlook-set-message-read-status';+import { outlookUpdateFocusedInboxOverrideAction } from './lib/actions/outlook-update-focused-inbox-override';+import { outlookUpdateMailFolderAction } from './lib/actions/outlook-update-mail-folder';+import { outlookUpdateMessageAction } from './lib/actions/outlook-update-message';export const microsoftOutlook = createPiece({displayName: 'Microsoft Outlook',@@ -37,6 +82,51 @@ export const microsoftOutlook = createPiece({sendDraftEmailAction,forwardEmailAction,findEmailAction,+ outlookListMessagesAction,+ outlookGetMessageAction,+ outlookSearchMessagesAction,+ outlookGetMessageMimeAction,+ outlookListMessagesDeltaAction,+ outlookSendEmailAction,+ outlookCreateDraftAction,+ outlookSendDraftAction,+ outlookReplyToMessageAction,+ outlookReplyAllToMessageAction,+ outlookForwardMessageAction,+ outlookCreateReplyDraftAction,+ outlookCreateReplyAllDraftAction,+ outlookCreateForwardDraftAction,+ outlookUpdateMessageAction,+ outlookSetMessageReadStatusAction,+ outlookMoveMessageAction,+ outlookCopyMessageAction,+ outlookDeleteMessageAction,+ outlookPermanentlyDeleteMessageAction,+ outlookBatchMoveMessagesAction,+ outlookBatchUpdateMessagesAction,+ outlookAddMessageCategoriesAction,+ outlookRemoveMessageCategoriesAction,+ outlookListMessageAttachmentsAction,+ outlookGetMessageAttachmentAction,+ outlookDownloadMessageAttachmentAction,+ outlookAddMessageAttachmentAction,+ outlookDeleteMessageAttachmentAction,+ outlookListMailFoldersAction,+ outlookListChildMailFoldersAction,+ outlookGetMailFolderAction,+ outlookCreateMailFolderAction,+ outlookUpdateMailFolderAction,+ outlookDeleteMailFolderAction,+ outlookCopyMailFolderAction,+ outlookMoveMailFolderAction,+ outlookListMailFoldersDeltaAction,+ outlookListFocusedInboxOverridesAction,+ outlookCreateFocusedInboxOverrideAction,+ outlookUpdateFocusedInboxOverrideAction,+ outlookDeleteFocusedInboxOverrideAction,+ outlookGetMailTipsAction,+ outlookGetMyProfileAction,+ outlookGetSupportedTimeZonesAction,createCustomApiCallAction({auth: microsoftOutlookAuth,baseUrl: (auth) => {diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/add-label-to-email.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/add-label-to-email.tsindex 15a8397f26e..da396b83470 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/actions/add-label-to-email.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/add-label-to-email.ts@@ -10,7 +10,7 @@ export const addLabelToEmailAction = createAction({classification: 'WRITE',displayName: 'Add Label to Email',description: 'Adds a category (label) to an email message.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Adds one or more Outlook categories (labels) to a specific message, merging them with any categories already present. Use this to tag or classify an email. Idempotent: re-adding the same categories leaves the message unchanged since duplicates are de-duplicated.', idempotent: true },outputSchema: messageActionOutputSchema,props: {diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/batch-output-shape.test.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/batch-output-shape.test.tsnew file mode 100644index 00000000000..493bd8048d2--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/batch-output-shape.test.ts@@ -0,0 +1,131 @@+import { beforeEach, describe, expect, it, vi } from 'vitest';++const { runGraphBatchMock } = vi.hoisted(() => ({ runGraphBatchMock: vi.fn() }));++vi.mock('../common/graph-batch', async () => {+ const actual = await vi.importActual<typeof import('../common/graph-batch')>(+ '../common/graph-batch',+ );+ return { ...actual, runGraphBatch: runGraphBatchMock };+});++vi.mock('../common/client', () => ({+ outlookCommon: {+ createClient: () => ({}),+ mailboxPrefix: () => '/me',+ },+}));++import { outlookBatchMoveMessagesAction } from './outlook-batch-move-messages';+import { outlookBatchUpdateMessagesAction } from './outlook-batch-update-messages';++const auth = { access_token: 'token' } as never;++function run(action: { run: (context: never) => Promise<unknown> }, propsValue: unknown) {+ return action.run({ auth, propsValue } as never);+}++describe('outlook batch actions share one output contract', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ });++ it('batch_update_messages returns succeeded as objects carrying messageId', async () => {+ runGraphBatchMock.mockResolvedValueOnce([+ { id: '1', status: 200, body: { id: 'm1' } },+ { id: '2', status: 200, body: { id: 'm2' } },+ ]);++ const result = (await run(outlookBatchUpdateMessagesAction, {+ messageIds: ['m1', 'm2'],+ isRead: 'true',+ })) as Record<string, unknown>;++ expect(result['succeeded']).toEqual([{ messageId: 'm1' }, { messageId: 'm2' }]);+ expect(result['success']).toBe(true);+ expect(result['requestedCount']).toBe(2);+ expect(result['succeededCount']).toBe(2);+ expect(result['failedCount']).toBe(0);+ expect(result['failed']).toEqual([]);+ });++ it('batch_move_messages returns succeeded as objects carrying messageId', async () => {+ runGraphBatchMock.mockResolvedValueOnce([+ { id: '1', status: 201, body: { id: 'new-1' } },+ ]);++ const result = (await run(outlookBatchMoveMessagesAction, {+ messageIds: ['m1'],+ destinationFolderId: 'archive',+ })) as Record<string, unknown>;++ expect(result['succeeded']).toEqual([{ messageId: 'm1', newMessageId: 'new-1' }]);+ expect(result['success']).toBe(true);+ expect(result['succeededCount']).toBe(1);+ });++ it('every succeeded entry of both actions is an object with a messageId', async () => {+ runGraphBatchMock.mockResolvedValueOnce([{ id: '1', status: 200, body: { id: 'm1' } }]);+ const updated = (await run(outlookBatchUpdateMessagesAction, {+ messageIds: ['m1'],+ isRead: 'true',+ })) as { succeeded: Array<Record<string, unknown>> };++ runGraphBatchMock.mockResolvedValueOnce([{ id: '1', status: 201, body: { id: 'new-1' } }]);+ const moved = (await run(outlookBatchMoveMessagesAction, {+ messageIds: ['m1'],+ destinationFolderId: 'archive',+ })) as { succeeded: Array<Record<string, unknown>> };++ for (const entry of [...updated.succeeded, ...moved.succeeded]) {+ expect(typeof entry).toBe('object');+ expect(typeof entry['messageId']).toBe('string');+ }+ });++ it('reports partial failure identically on both actions', async () => {+ const mixed = [+ { id: '1', status: 200, body: { id: 'm1' } },+ { id: '2', status: 404, body: { error: { code: 'ErrorItemNotFound', message: 'gone' } } },+ ];++ runGraphBatchMock.mockResolvedValueOnce(mixed);+ const updated = (await run(outlookBatchUpdateMessagesAction, {+ messageIds: ['m1', 'm2'],+ isRead: 'true',+ })) as Record<string, unknown>;++ runGraphBatchMock.mockResolvedValueOnce(mixed);+ const moved = (await run(outlookBatchMoveMessagesAction, {+ messageIds: ['m1', 'm2'],+ destinationFolderId: 'archive',+ })) as Record<string, unknown>;++ for (const result of [updated, moved]) {+ expect(result['success']).toBe(false);+ expect(result['succeededCount']).toBe(1);+ expect(result['failedCount']).toBe(1);+ expect(result['failed']).toEqual([+ { messageId: 'm2', status: 404, error: 'ErrorItemNotFound: gone' },+ ]);+ }+ });++ it('merges categories per message before patching', async () => {+ runGraphBatchMock+ .mockResolvedValueOnce([+ { id: '1', status: 200, body: { id: 'm1', categories: ['keep'] } },+ ])+ .mockResolvedValueOnce([{ id: '1', status: 200, body: { id: 'm1' } }]);++ await run(outlookBatchUpdateMessagesAction, {+ messageIds: ['m1'],+ categoriesToAdd: ['added'],+ });++ const patchCall = runGraphBatchMock.mock.calls[1][0] as {+ requests: Array<{ body: { categories: string[] } }>;+ };+ expect(patchCall.requests[0].body.categories).toEqual(['keep', 'added']);+ });+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/create-draft-email.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/create-draft-email.tsindex 4fa22b2a2d6..b2369ee66e3 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/actions/create-draft-email.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/create-draft-email.ts@@ -10,7 +10,7 @@ export const createDraftEmailAction = createAction({classification: 'WRITE',displayName: 'Create Draft Email',description: 'Creates a draft email message.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Creates a new unsent draft email in the Outlook mailbox with recipients, subject, body, and optional attachments. Use this to stage a message for later review or sending (pair with Send Draft Email). Not idempotent: each call creates a separate draft.', idempotent: false },outputSchema: draftMessageActionOutputSchema,props: {diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/find-email.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/find-email.tsindex aaf7b1ac77b..15a9f3d012e 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/actions/find-email.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/find-email.ts@@ -13,7 +13,7 @@ export const findEmailAction = createAction({classification: 'SEARCH',displayName: 'Find Email',description: 'Searches for emails using full-text search.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Searches the Outlook mailbox for messages matching a full-text query (supports field syntax like from:, subject:, hasAttachments:), optionally scoped to one folder and capped by a max-results count. Use this to locate emails and obtain their message IDs for follow-up actions. Idempotent read-only lookup.', idempotent: true },outputSchema: findEmailActionOutputSchema,props: {diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/forward-email.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/forward-email.tsindex a0efa57fd83..004d5b35800 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/actions/forward-email.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/forward-email.ts@@ -11,7 +11,7 @@ export const forwardEmailAction = createAction({classification: 'WRITE',displayName: 'Forward Email',description: 'Forwards an email message.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Forwards an existing Outlook message (by message ID) to new recipients, preserving the original body and attachments and prepending an optional comment. Use this to pass an existing email along rather than composing a new one. Not idempotent: each call sends a new forwarded email.', idempotent: false },outputSchema: forwardEmailActionOutputSchema,props: {diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/move-email-to-folder.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/move-email-to-folder.tsindex b34525f3df4..75a0635c4b3 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/actions/move-email-to-folder.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/move-email-to-folder.ts@@ -10,7 +10,7 @@ export const moveEmailToFolderAction = createAction({classification: 'WRITE',displayName: 'Move Email to Folder',description: 'Moves an email message to a specific folder.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Moves a specific Outlook message into a chosen mail folder. Use this to organize, archive, or route an email after processing it. Note: the move assigns a new message ID, so re-running with the original ID will fail once moved.', idempotent: false },outputSchema: messageActionOutputSchema,props: {diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-add-message-attachment.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-add-message-attachment.tsnew file mode 100644index 00000000000..49eccf80d40--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-add-message-attachment.ts@@ -0,0 +1,72 @@+import { ApFile, createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookAddMessageAttachmentActionOutputSchema } from '../output-schemas';++export const outlookAddMessageAttachmentAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_add_message_attachment',+ classification: 'WRITE',+ displayName: 'Add Attachment to Draft',+ description: 'Attaches a file to a draft message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Attaches one file to an existing draft message and returns the created attachment metadata without echoing the file bytes back. Only meaningful on drafts, and only for files under 3 MB; larger files need an upload session, which this piece does not expose yet. Pair it with Create Draft and Send Draft. Not idempotent: each call adds another attachment, even with the same file name.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Draft Message ID',+ description: 'ID of the draft to attach the file to. Obtain it from Create Draft.',+ required: true,+ }),+ file: Property.File({+ displayName: 'File',+ description: 'File to attach. Must be smaller than 3 MB.',+ required: true,+ }),+ fileName: Property.ShortText({+ displayName: 'File Name',+ description: 'Name shown on the attachment. Defaults to the uploaded file name.',+ required: false,+ }),+ },+ outputSchema: outlookAddMessageAttachmentActionOutputSchema,+ async run(context) {+ const { messageId, fileName } = context.propsValue;+ const file = context.propsValue.file as ApFile;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const attachment = await client+ .api(+ `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/attachments`,+ )+ .post({+ '@odata.type': '#microsoft.graph.fileAttachment',+ name: fileName || file.filename,+ contentBytes: file.base64,+ });++ return {+ messageId,+ id: attachment?.['id'] ?? null,+ name: attachment?.['name'] ?? null,+ contentType: attachment?.['contentType'] ?? null,+ size: attachment?.['size'] ?? null,+ isInline: attachment?.['isInline'] ?? null,+ lastModifiedDateTime: attachment?.['lastModifiedDateTime'] ?? null,+ attachmentType: attachment?.['@odata.type'] ?? null,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Adding the attachment to the Outlook draft',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-add-message-categories.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-add-message-categories.tsnew file mode 100644index 00000000000..4b2bba5302d--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-add-message-categories.ts@@ -0,0 +1,56 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookMessageActionOutputSchema } from '../output-schemas';++export const outlookAddMessageCategoriesAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_add_message_categories',+ classification: 'WRITE',+ displayName: 'Add Categories to Message',+ description: 'Adds categories (labels) to a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Adds one or more Outlook categories to a message, merging them with the categories already on it so nothing is overwritten. Use Remove Categories from Message for the inverse, and Update Message when other fields change too. Idempotent: re-adding the same categories leaves the message unchanged.',+ idempotent: true,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ categories: Property.Array({+ displayName: 'Categories',+ description: 'Category names to add to the message.',+ required: true,+ }),+ },+ outputSchema: outlookMessageActionOutputSchema,+ async run(context) {+ const { messageId } = context.propsValue;+ const categories = context.propsValue.categories as string[];++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const path = `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}`;++ try {+ const current = await client.api(`${path}?$select=id,categories`).get();+ const existing = (current?.['categories'] ?? []) as string[];+ const merged = [...new Set([...existing, ...categories])];++ return await client+ .api(path)+ .headers(outlookAtomicCommon.textBodyHeaders)+ .patch({ categories: merged });+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Adding categories to the Outlook message',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-batch-move-messages.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-batch-move-messages.tsnew file mode 100644index 00000000000..c4db8685439--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-batch-move-messages.ts@@ -0,0 +1,85 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { describeBatchFailure, GraphBatchRequest, runGraphBatch } from '../common/graph-batch';+import { outlookBatchMoveMessagesActionOutputSchema } from '../output-schemas';++export const outlookBatchMoveMessagesAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_batch_move_messages',+ classification: 'WRITE',+ displayName: 'Batch Move Messages',+ description: 'Moves several messages to one folder in a single batched call.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Moves many messages into the same destination folder using Microsoft Graph batching, in chunks of 20 sub-requests. Every moved message gets a NEW ID, returned per item, and the original IDs stop resolving. Individual items can fail while others succeed, so always read the failed list. Use Move Message for a single message. Not idempotent: a retry with the old IDs fails.',+ idempotent: false,+ },+ props: {+ messageIds: Property.Array({+ displayName: 'Message IDs',+ description: 'IDs of the messages to move. Resolve them with List Messages or Search Messages.',+ required: true,+ }),+ destinationFolderId: Property.ShortText({+ displayName: 'Destination Folder ID',+ description: outlookAtomicCommon.wellKnownFolderHint,+ required: true,+ }),+ },+ outputSchema: outlookBatchMoveMessagesActionOutputSchema,+ async run(context) {+ const { destinationFolderId } = context.propsValue;+ const messageIds = (context.propsValue.messageIds ?? []) as string[];++ if (messageIds.length === 0) {+ throw new Error('Batch moving Outlook messages failed: no message IDs were supplied.');+ }++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ const requests: GraphBatchRequest[] = messageIds.map((messageId, index) => ({+ id: String(index + 1),+ method: 'POST',+ url: `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/move`,+ headers: { 'Content-Type': 'application/json' },+ body: { destinationId: destinationFolderId },+ }));++ try {+ const responses = await runGraphBatch({ client, requests });++ const succeeded: Array<{ messageId: string; newMessageId: string | null }> = [];+ const failed: Array<{ messageId: string; status: number; error: string }> = [];++ for (const response of responses) {+ const messageId = messageIds[Number(response.id) - 1];+ if (response.status >= 200 && response.status < 300) {+ const body = (response.body ?? {}) as { id?: string };+ succeeded.push({ messageId, newMessageId: body.id ?? null });+ } else {+ failed.push({+ messageId,+ status: response.status,+ error: describeBatchFailure(response),+ });+ }+ }++ return {+ success: failed.length === 0,+ destinationFolderId,+ requestedCount: messageIds.length,+ succeededCount: succeeded.length,+ failedCount: failed.length,+ succeeded,+ failed,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Batch moving Outlook messages' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-batch-update-messages.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-batch-update-messages.tsnew file mode 100644index 00000000000..3aec2fa888b--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-batch-update-messages.ts@@ -0,0 +1,190 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { FollowupFlagStatus, Importance, Message } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { describeBatchFailure, GraphBatchRequest, runGraphBatch } from '../common/graph-batch';+import { outlookBatchUpdateMessagesActionOutputSchema } from '../output-schemas';++export const outlookBatchUpdateMessagesAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_batch_update_messages',+ classification: 'WRITE',+ displayName: 'Batch Update Messages',+ description: 'Applies the same property changes to several messages at once.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Applies the same read state, flag, importance and category changes to many messages through Microsoft Graph batching, in chunks of 20 sub-requests. Fields left empty are never sent, and categories are merged per message against that message current categories, so tags on other messages are not wiped. Individual items can fail while others succeed, so always read the failed list. Idempotent: re-applying the same field values converges on the same state and creates no new entities.',+ idempotent: true,+ },+ props: {+ messageIds: Property.Array({+ displayName: 'Message IDs',+ description: 'IDs of the messages to update. Resolve them with List Messages or Search Messages.',+ required: true,+ }),+ isRead: Property.StaticDropdown({+ displayName: 'Read State',+ description: 'Leave unset to keep each message current read state.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Mark as read', value: 'true' },+ { label: 'Mark as unread', value: 'false' },+ ],+ },+ }),+ flagStatus: Property.StaticDropdown({+ displayName: 'Flag State',+ description: 'Leave unset to keep each message current flag.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Flagged', value: 'flagged' },+ { label: 'Not flagged', value: 'notFlagged' },+ { label: 'Complete', value: 'complete' },+ ],+ },+ }),+ importance: Property.StaticDropdown({+ displayName: 'Importance',+ description: 'Leave unset to keep each message current importance.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Low', value: 'low' },+ { label: 'Normal', value: 'normal' },+ { label: 'High', value: 'high' },+ ],+ },+ }),+ categoriesToAdd: Property.Array({+ displayName: 'Categories to Add',+ description: 'Category names merged into the categories each message already has.',+ required: false,+ }),+ categoriesToRemove: Property.Array({+ displayName: 'Categories to Remove',+ description: 'Category names removed from each message.',+ required: false,+ }),+ },+ outputSchema: outlookBatchUpdateMessagesActionOutputSchema,+ async run(context) {+ const { isRead, flagStatus, importance } = context.propsValue;+ const messageIds = (context.propsValue.messageIds ?? []) as string[];+ const categoriesToAdd = (context.propsValue.categoriesToAdd ?? []) as string[];+ const categoriesToRemove = (context.propsValue.categoriesToRemove ?? []) as string[];++ if (messageIds.length === 0) {+ throw new Error('Batch updating Outlook messages failed: no message IDs were supplied.');+ }++ const basePayload: Message = {};+ if (isRead !== undefined) {+ basePayload.isRead = isRead === 'true';+ }+ if (flagStatus !== undefined) {+ basePayload.flag = { flagStatus: flagStatus as FollowupFlagStatus };+ }+ if (importance !== undefined) {+ basePayload.importance = importance as Importance;+ }++ const changesCategories = categoriesToAdd.length > 0 || categoriesToRemove.length > 0;++ if (Object.keys(basePayload).length === 0 && !changesCategories) {+ throw new Error(+ 'Batch updating Outlook messages failed: no fields were supplied, so there is nothing to change.',+ );+ }++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ const failed: Array<{ messageId: string; status: number; error: string }> = [];+ const mergedCategories = new Map<string, string[]>();++ try {+ if (changesCategories) {+ const readRequests: GraphBatchRequest[] = messageIds.map((messageId, index) => ({+ id: String(index + 1),+ method: 'GET',+ url: `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(+ messageId,+ )}?$select=id,categories`,+ }));++ const readResponses = await runGraphBatch({ client, requests: readRequests });++ for (const response of readResponses) {+ const messageId = messageIds[Number(response.id) - 1];+ if (response.status >= 200 && response.status < 300) {+ const body = (response.body ?? {}) as { categories?: string[] };+ const existing = body.categories ?? [];+ mergedCategories.set(+ messageId,+ [...new Set([...existing, ...categoriesToAdd])].filter(+ (category) => !categoriesToRemove.includes(category),+ ),+ );+ } else {+ failed.push({+ messageId,+ status: response.status,+ error: describeBatchFailure(response),+ });+ }+ }+ }++ const targets = changesCategories+ ? messageIds.filter((messageId) => mergedCategories.has(messageId))+ : messageIds;++ const patchRequests: GraphBatchRequest[] = targets.map((messageId, index) => ({+ id: String(index + 1),+ method: 'PATCH',+ url: `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}`,+ headers: { 'Content-Type': 'application/json' },+ body: changesCategories+ ? { ...basePayload, categories: mergedCategories.get(messageId) }+ : { ...basePayload },+ }));++ const succeeded: Array<{ messageId: string }> = [];++ if (patchRequests.length > 0) {+ const patchResponses = await runGraphBatch({ client, requests: patchRequests });++ for (const response of patchResponses) {+ const messageId = targets[Number(response.id) - 1];+ if (response.status >= 200 && response.status < 300) {+ succeeded.push({ messageId });+ } else {+ failed.push({+ messageId,+ status: response.status,+ error: describeBatchFailure(response),+ });+ }+ }+ }++ return {+ success: failed.length === 0,+ requestedCount: messageIds.length,+ succeededCount: succeeded.length,+ failedCount: failed.length,+ succeeded,+ failed,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Batch updating Outlook messages' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-copy-mail-folder.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-copy-mail-folder.tsnew file mode 100644index 00000000000..73bd958e6ec--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-copy-mail-folder.ts@@ -0,0 +1,58 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { MailFolder } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookCopyMailFolderActionOutputSchema } from '../output-schemas';++export const outlookCopyMailFolderAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_copy_mail_folder',+ classification: 'WRITE',+ displayName: 'Copy Mail Folder',+ description: 'Copies a mail folder under another folder.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Copies a mail folder, with its messages and sub-folders, under a destination folder and returns the new folder. Use Move Mail Folder when the original should not stay in place. Not idempotent: each call creates another copy.',+ idempotent: false,+ },+ props: {+ folderId: Property.ShortText({+ displayName: 'Folder ID',+ description: outlookAtomicCommon.wellKnownFolderHint,+ required: true,+ }),+ destinationFolderId: Property.ShortText({+ displayName: 'Destination Folder ID',+ description: `Folder that will contain the copy. ${outlookAtomicCommon.wellKnownFolderHint}`,+ required: true,+ }),+ },+ outputSchema: outlookCopyMailFolderActionOutputSchema,+ async run(context) {+ const { folderId, destinationFolderId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const copied: MailFolder = await client+ .api(`${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(folderId)}/copy`)+ .post({ destinationId: destinationFolderId });++ return {+ success: true,+ sourceFolderId: folderId,+ newFolderId: copied?.id ?? null,+ destinationFolderId,+ folder: copied,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Copying the Outlook mail folder',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-copy-message.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-copy-message.tsnew file mode 100644index 00000000000..db8e39aefe8--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-copy-message.ts@@ -0,0 +1,55 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { Message } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookCopyMessageActionOutputSchema } from '../output-schemas';++export const outlookCopyMessageAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_copy_message',+ classification: 'WRITE',+ displayName: 'Copy Message',+ description: 'Copies a message into another mail folder.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Copies one message into another mail folder, leaving the original where it is, and returns the copy. The copy has a NEW message ID, returned as newMessageId. Use Move Message when the original should not stay behind. Not idempotent: each call creates one more copy.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ destinationFolderId: Property.ShortText({+ displayName: 'Destination Folder ID',+ description: outlookAtomicCommon.wellKnownFolderHint,+ required: true,+ }),+ },+ outputSchema: outlookCopyMessageActionOutputSchema,+ async run(context) {+ const { messageId, destinationFolderId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const copied: Message = await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/copy`)+ .post({ destinationId: destinationFolderId });++ return {+ success: true,+ sourceMessageId: messageId,+ newMessageId: copied?.id ?? null,+ destinationFolderId,+ message: copied,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Copying the Outlook message' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-draft.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-draft.tsnew file mode 100644index 00000000000..661a017d83b--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-draft.ts@@ -0,0 +1,114 @@+import { ApFile, createAction, Property } from '@activepieces/pieces-framework';+import { BodyType, Message } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookDraftMessageActionOutputSchema } from '../output-schemas';++export const outlookCreateDraftAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_create_draft',+ classification: 'WRITE',+ displayName: 'Create Draft',+ description: 'Creates an unsent draft message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates an unsent draft email in the mailbox (optionally inside a specific folder) and returns its message ID. Use this to stage a message for review, to attach files with Add Attachment to Draft, or before Send Draft; use Send Email to send in one step. Not idempotent: every call creates another draft.',+ idempotent: false,+ },+ props: {+ recipients: Property.Array({+ displayName: 'To Email(s)',+ required: false,+ }),+ ccRecipients: Property.Array({+ displayName: 'CC Email(s)',+ required: false,+ }),+ bccRecipients: Property.Array({+ displayName: 'BCC Email(s)',+ required: false,+ }),+ subject: Property.ShortText({+ displayName: 'Subject',+ required: true,+ }),+ bodyFormat: Property.StaticDropdown({+ displayName: 'Body Format',+ required: true,+ defaultValue: 'text',+ options: {+ disabled: false,+ options: [+ { label: 'HTML', value: 'html' },+ { label: 'Text', value: 'text' },+ ],+ },+ }),+ body: Property.LongText({+ displayName: 'Body',+ required: true,+ }),+ folderId: Property.ShortText({+ displayName: 'Folder ID',+ description: `Create the draft inside a specific folder. ${outlookAtomicCommon.wellKnownFolderHint} Leave empty to use the Drafts folder.`,+ required: false,+ }),+ attachments: Property.Array({+ displayName: 'Attachments',+ description: 'Files to attach. Total message size must stay under 3 MB.',+ required: false,+ properties: {+ file: Property.File({+ displayName: 'File',+ required: true,+ }),+ fileName: Property.ShortText({+ displayName: 'File Name',+ required: false,+ }),+ },+ }),+ },+ outputSchema: outlookDraftMessageActionOutputSchema,+ async run(context) {+ const recipients = (context.propsValue.recipients ?? []) as string[];+ const ccRecipients = (context.propsValue.ccRecipients ?? []) as string[];+ const bccRecipients = (context.propsValue.bccRecipients ?? []) as string[];+ const attachments = (context.propsValue.attachments ?? []) as Array<{+ file: ApFile;+ fileName: string;+ }>;++ const { subject, body, bodyFormat, folderId } = context.propsValue;++ const mailPayload: Message = {+ subject,+ body: {+ content: body,+ contentType: bodyFormat as BodyType,+ },+ toRecipients: recipients.map((mail) => ({ emailAddress: { address: mail } })),+ ccRecipients: ccRecipients.map((mail) => ({ emailAddress: { address: mail } })),+ bccRecipients: bccRecipients.map((mail) => ({ emailAddress: { address: mail } })),+ attachments: attachments.map((attachment) => ({+ '@odata.type': '#microsoft.graph.fileAttachment',+ name: attachment.fileName || attachment.file.filename,+ contentBytes: attachment.file.base64,+ })),+ };++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const path = folderId+ ? `${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(folderId)}/messages`+ : `${prefix}/messages`;++ try {+ return await client.api(path).post(mailPayload);+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Creating the Outlook draft' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-focused-inbox-override.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-focused-inbox-override.tsnew file mode 100644index 00000000000..501a9e7049e--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-focused-inbox-override.ts@@ -0,0 +1,65 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookFocusedInboxOverrideActionOutputSchema } from '../output-schemas';++export const outlookCreateFocusedInboxOverrideAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_create_focused_inbox_override',+ classification: 'WRITE',+ displayName: 'Create Focused Inbox Override',+ description: 'Forces mail from a sender into the Focused or Other tab.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Pins future mail from one sender address to the Focused or the Other tab. Microsoft upserts by sender address: if an override already exists for that address, its classification is updated instead of a duplicate being created, and the stored display name is left untouched unless Sender Display Name is supplied. Idempotent for that reason. Use Update Focused Inbox Override when you already hold an override ID.',+ idempotent: true,+ },+ props: {+ senderEmailAddress: Property.ShortText({+ displayName: 'Sender Email Address',+ description: 'SMTP address of the sender the override applies to.',+ required: true,+ }),+ classifyAs: Property.StaticDropdown({+ displayName: 'Classify As',+ required: true,+ defaultValue: 'focused',+ options: {+ disabled: false,+ options: [+ { label: 'Focused', value: 'focused' },+ { label: 'Other', value: 'other' },+ ],+ },+ }),+ senderName: Property.ShortText({+ displayName: 'Sender Display Name',+ description: 'Optional display name stored alongside the override.',+ required: false,+ }),+ },+ outputSchema: outlookFocusedInboxOverrideActionOutputSchema,+ async run(context) {+ const { senderEmailAddress, classifyAs, senderName } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ return await client.api(`${prefix}/inferenceClassification/overrides`).post({+ classifyAs,+ senderEmailAddress: {+ ...(senderName ? { name: senderName } : {}),+ address: senderEmailAddress,+ },+ });+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Creating the Focused Inbox override',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-forward-draft.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-forward-draft.tsnew file mode 100644index 00000000000..4ccc07e7d31--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-forward-draft.ts@@ -0,0 +1,58 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookDraftMessageActionOutputSchema } from '../output-schemas';++export const outlookCreateForwardDraftAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_create_forward_draft',+ classification: 'WRITE',+ displayName: 'Create Forward Draft',+ description: 'Creates an unsent forward draft for a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates an unsent draft that forwards an existing message to the given recipients, and returns the draft message ID so the forward can be edited before sending. Use Forward Message to send in one step, and Send Draft to dispatch this draft. Not idempotent: each call creates another draft.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ recipients: Property.Array({+ displayName: 'To Email(s)',+ description: 'Email addresses the draft will forward the message to.',+ required: true,+ }),+ comment: Property.LongText({+ displayName: 'Comment',+ description: 'Optional text added above the forwarded message.',+ required: false,+ }),+ },+ outputSchema: outlookDraftMessageActionOutputSchema,+ async run(context) {+ const { messageId, comment } = context.propsValue;+ const recipients = context.propsValue.recipients as string[];++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ return await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/createForward`)+ .post({+ comment: comment ?? '',+ toRecipients: recipients.map((mail) => ({ emailAddress: { address: mail } })),+ });+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Creating the Outlook forward draft',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-mail-folder.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-mail-folder.tsnew file mode 100644index 00000000000..821706947d0--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-mail-folder.ts@@ -0,0 +1,80 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { MailFolder } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookCreateMailFolderActionOutputSchema } from '../output-schemas';++export const outlookCreateMailFolderAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_create_mail_folder',+ classification: 'WRITE',+ displayName: 'Create Mail Folder',+ description: 'Creates a mail folder, or returns the existing one with the same name.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates a mail folder at the top level or under a parent folder. It first queries the sibling folders by exact display name and returns the existing folder with created set to false when one already carries the same display name, so no duplicate folder is ever created. Idempotent: repeat calls return the same folder.',+ idempotent: true,+ },+ props: {+ displayName: Property.ShortText({+ displayName: 'Folder Name',+ description: 'Display name of the folder to create.',+ required: true,+ }),+ parentFolderId: Property.ShortText({+ displayName: 'Parent Folder ID',+ description: `Create the folder under this parent. ${outlookAtomicCommon.wellKnownFolderHint} Leave empty to create it at the top level.`,+ required: false,+ }),+ },+ outputSchema: outlookCreateMailFolderActionOutputSchema,+ async run(context) {+ const { displayName, parentFolderId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const collectionPath = parentFolderId+ ? `${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(parentFolderId)}/childFolders`+ : `${prefix}/mailFolders`;++ const wantedName = displayName.trim();++ try {+ const siblings: PageCollection = await client+ .api(+ `${collectionPath}?includeHiddenFolders=true&$select=${+ outlookAtomicCommon.mailFolderSelect+ }&$filter=${encodeURIComponent(`displayName eq '${wantedName.replace(/'/g, "''")}'`)}`,+ )+ .get();++ const existing = ((siblings.value ?? []) as MailFolder[]).find(+ (folder) => (folder.displayName ?? '').toLowerCase() === wantedName.toLowerCase(),+ );++ if (existing) {+ return {+ created: false,+ folder: existing,+ folderId: existing.id ?? null,+ };+ }++ const folder: MailFolder = await client.api(collectionPath).post({ displayName });++ return {+ created: true,+ folder,+ folderId: folder?.id ?? null,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Creating the Outlook mail folder',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-reply-all-draft.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-reply-all-draft.tsnew file mode 100644index 00000000000..134f0a192c7--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-reply-all-draft.ts@@ -0,0 +1,49 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookDraftMessageActionOutputSchema } from '../output-schemas';++export const outlookCreateReplyAllDraftAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_create_reply_all_draft',+ classification: 'WRITE',+ displayName: 'Create Reply-All Draft',+ description: 'Creates an unsent reply-all draft for a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates an unsent draft addressed to the sender and every other recipient of an existing message, and returns the draft message ID. Use Create Reply Draft to answer only the sender, or Reply All to Message to send immediately. Send it later with Send Draft. Not idempotent: each call creates another draft.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ comment: Property.LongText({+ displayName: 'Reply Text',+ description: 'Optional text added above the quoted original message.',+ required: false,+ }),+ },+ outputSchema: outlookDraftMessageActionOutputSchema,+ async run(context) {+ const { messageId, comment } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ return await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/createReplyAll`)+ .post({ comment: comment ?? '' });+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Creating the Outlook reply-all draft',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-reply-draft.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-reply-draft.tsnew file mode 100644index 00000000000..0f059a72f44--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-create-reply-draft.ts@@ -0,0 +1,49 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookDraftMessageActionOutputSchema } from '../output-schemas';++export const outlookCreateReplyDraftAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_create_reply_draft',+ classification: 'WRITE',+ displayName: 'Create Reply Draft',+ description: 'Creates an unsent reply draft for a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates an unsent draft reply to the sender of an existing message and returns the draft message ID. Use this when the reply needs editing, extra attachments or review before it goes out; use Reply to Message to send in one step, and Send Draft to dispatch the draft afterwards. Not idempotent: each call creates another draft.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ comment: Property.LongText({+ displayName: 'Reply Text',+ description: 'Optional text added above the quoted original message.',+ required: false,+ }),+ },+ outputSchema: outlookDraftMessageActionOutputSchema,+ async run(context) {+ const { messageId, comment } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ return await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/createReply`)+ .post({ comment: comment ?? '' });+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Creating the Outlook reply draft',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-focused-inbox-override.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-focused-inbox-override.tsnew file mode 100644index 00000000000..c3b3b626ef0--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-focused-inbox-override.ts@@ -0,0 +1,54 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookDeleteFocusedInboxOverrideActionOutputSchema } from '../output-schemas';++export const outlookDeleteFocusedInboxOverrideAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_delete_focused_inbox_override',+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Focused Inbox Override',+ description: 'Removes a Focused Inbox sender override.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Deletes one Focused Inbox override so mail from that sender is classified by Outlook again. The override ID comes from List Focused Inbox Overrides. Not idempotent: repeating the call with the same ID fails once the override is gone.',+ idempotent: false,+ },+ props: {+ overrideId: Property.ShortText({+ displayName: 'Override ID',+ description: 'Override ID from List Focused Inbox Overrides.',+ required: true,+ }),+ },+ outputSchema: outlookDeleteFocusedInboxOverrideActionOutputSchema,+ async run(context) {+ const { overrideId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ await client+ .api(+ `${prefix}/inferenceClassification/overrides/${outlookAtomicCommon.encodeGraphId(+ overrideId,+ )}`,+ )+ .delete();++ return {+ success: true,+ message: 'Focused Inbox override deleted.',+ overrideId,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Deleting the Focused Inbox override',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-mail-folder.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-mail-folder.tsnew file mode 100644index 00000000000..3cc28d59ba0--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-mail-folder.ts@@ -0,0 +1,50 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookDeleteMailFolderActionOutputSchema } from '../output-schemas';++export const outlookDeleteMailFolderAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_delete_mail_folder',+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Mail Folder',+ description: 'Deletes a mail folder and everything inside it.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Deletes a mail folder together with every message and sub-folder it contains. Move messages out with Batch Move Messages first if they must be kept. Not idempotent: repeating the call with the same ID fails once the folder is gone.',+ idempotent: false,+ },+ props: {+ folderId: Property.ShortText({+ displayName: 'Folder ID',+ description: `${outlookAtomicCommon.wellKnownFolderHint} Well-known system folders cannot be deleted.`,+ required: true,+ }),+ },+ outputSchema: outlookDeleteMailFolderActionOutputSchema,+ async run(context) {+ const { folderId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ await client+ .api(`${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(folderId)}`)+ .delete();++ return {+ success: true,+ message: 'Mail folder deleted.',+ folderId,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Deleting the Outlook mail folder',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-message-attachment.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-message-attachment.tsnew file mode 100644index 00000000000..202751a3bce--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-message-attachment.ts@@ -0,0 +1,60 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookDeleteMessageAttachmentActionOutputSchema } from '../output-schemas';++export const outlookDeleteMessageAttachmentAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_delete_message_attachment',+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Message Attachment',+ description: 'Removes an attachment from a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Removes one attachment from a message, typically a draft, and it cannot be restored afterwards. Resolve the attachment ID with List Message Attachments first. Not idempotent: repeating the call with the same ID fails once the attachment is gone.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ attachmentId: Property.ShortText({+ displayName: 'Attachment ID',+ description: 'Attachment ID from List Message Attachments.',+ required: true,+ }),+ },+ outputSchema: outlookDeleteMessageAttachmentActionOutputSchema,+ async run(context) {+ const { messageId, attachmentId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ await client+ .api(+ `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(+ messageId,+ )}/attachments/${outlookAtomicCommon.encodeGraphId(attachmentId)}`,+ )+ .delete();++ return {+ success: true,+ message: 'Attachment deleted.',+ messageId,+ attachmentId,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Deleting the Outlook message attachment',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-message.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-message.tsnew file mode 100644index 00000000000..5bcc825a62b--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-delete-message.ts@@ -0,0 +1,47 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookDeleteMessageActionOutputSchema } from '../output-schemas';++export const outlookDeleteMessageAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_delete_message',+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Message (to Deleted Items)',+ description: 'Moves a message to the Deleted Items folder.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Deletes one message by moving it to Deleted Items, where it stays recoverable. This is the safe delete to prefer; Permanently Delete Message is unrecoverable. Not idempotent: repeating the call with the same ID fails once the message has moved.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ },+ outputSchema: outlookDeleteMessageActionOutputSchema,+ async run(context) {+ const { messageId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}`)+ .delete();++ return {+ success: true,+ message: 'Message moved to Deleted Items.',+ messageId,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Deleting the Outlook message' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-download-message-attachment.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-download-message-attachment.tsnew file mode 100644index 00000000000..6e90a62efcb--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-download-message-attachment.ts@@ -0,0 +1,94 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ResponseType } from '@microsoft/microsoft-graph-client';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookDownloadMessageAttachmentActionOutputSchema } from '../output-schemas';++export const outlookDownloadMessageAttachmentAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_download_message_attachment',+ classification: 'READ',+ displayName: 'Download Message Attachment',+ description: 'Downloads one file attachment of a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Downloads the bytes of a single file attachment and stores it for downstream steps. Only file attachments can be downloaded; item attachments (an attached email or event) and reference attachments (a cloud link) are rejected with an explanatory error, so check the attachment kind with List Message Attachments first. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ attachmentId: Property.ShortText({+ displayName: 'Attachment ID',+ description:+ 'Attachment ID from List Message Attachments. Attachment IDs are only valid inside their own message.',+ required: true,+ }),+ },+ outputSchema: outlookDownloadMessageAttachmentActionOutputSchema,+ async run(context) {+ const { messageId, attachmentId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const attachmentPath = `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(+ messageId,+ )}/attachments/${outlookAtomicCommon.encodeGraphId(attachmentId)}`;++ let metadata: Record<string, unknown>;+ try {+ metadata = await client+ .api(`${attachmentPath}?$select=${outlookAtomicCommon.attachmentSelect}`)+ .get();+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Reading the Outlook attachment before download',+ });+ }++ const attachmentType = (metadata?.['@odata.type'] ?? '') as string;++ if (attachmentType !== '#microsoft.graph.fileAttachment') {+ throw new Error(+ `Downloading the Outlook attachment failed: this attachment is a ${+ attachmentType || 'non-file attachment'+ }, and only #microsoft.graph.fileAttachment items expose downloadable bytes. Use List Message Attachments to find a file attachment on this message.`,+ );+ }++ try {+ const bytes = await client+ .api(`${attachmentPath}/$value`)+ .responseType(ResponseType.ARRAYBUFFER)+ .get();++ const buffer = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes);+ const fileName = (metadata?.['name'] as string | undefined) ?? 'attachment';++ const file = await context.files.write({+ fileName,+ data: buffer,+ });++ return {+ messageId,+ attachmentId,+ fileName,+ contentType: metadata?.['contentType'] ?? null,+ size: buffer.length,+ file,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Downloading the Outlook message attachment',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-forward-message.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-forward-message.tsnew file mode 100644index 00000000000..42e6814155a--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-forward-message.ts@@ -0,0 +1,62 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookForwardMessageActionOutputSchema } from '../output-schemas';++export const outlookForwardMessageAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_forward_message',+ classification: 'WRITE',+ displayName: 'Forward Message',+ description: 'Forwards a message to new recipients.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Forwards an existing message to new recipients, keeping the original body and attachments and prepending an optional comment. Use Create Forward Draft when the forward should be edited before sending. Not idempotent: each call sends another forwarded copy.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ recipients: Property.Array({+ displayName: 'To Email(s)',+ description: 'Email addresses to forward the message to.',+ required: true,+ }),+ comment: Property.LongText({+ displayName: 'Comment',+ description: 'Optional text added above the forwarded message.',+ required: false,+ }),+ },+ outputSchema: outlookForwardMessageActionOutputSchema,+ async run(context) {+ const { messageId, comment } = context.propsValue;+ const recipients = context.propsValue.recipients as string[];++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/forward`)+ .post({+ comment: comment ?? '',+ toRecipients: recipients.map((mail) => ({ emailAddress: { address: mail } })),+ });++ return {+ success: true,+ message: 'Message forwarded successfully.',+ messageId,+ recipients,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Forwarding the Outlook message' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-mail-folder.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-mail-folder.tsnew file mode 100644index 00000000000..80996589b08--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-mail-folder.ts@@ -0,0 +1,46 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookMailFolderActionOutputSchema } from '../output-schemas';++export const outlookGetMailFolderAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_get_mail_folder',+ classification: 'READ',+ displayName: 'Get Mail Folder',+ description: 'Reads one mail folder by ID or well-known name.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Reads a single mail folder and returns its display name, parent, child count and unread and total item counts. Accepts either an opaque folder ID or a well-known name such as inbox or drafts, which makes it the cheapest way to resolve a standard folder ID. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ folderId: Property.ShortText({+ displayName: 'Folder ID',+ description: outlookAtomicCommon.wellKnownFolderHint,+ required: true,+ defaultValue: 'inbox',+ }),+ },+ outputSchema: outlookMailFolderActionOutputSchema,+ async run(context) {+ const { folderId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ return await client+ .api(+ `${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(folderId)}?$select=${+ outlookAtomicCommon.mailFolderSelect+ }`,+ )+ .get();+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Reading the Outlook mail folder' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-mail-tips.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-mail-tips.tsnew file mode 100644index 00000000000..596e63b2394--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-mail-tips.ts@@ -0,0 +1,56 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookGetMailTipsActionOutputSchema } from '../output-schemas';++const mailTipsOptions =+ 'automaticReplies, mailboxFullStatus, customMailTip, externalMemberCount, maxMessageSize, deliveryRestriction, moderationStatus, recipientScope, totalMemberCount';++export const outlookGetMailTipsAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_get_mail_tips',+ classification: 'READ',+ displayName: 'Get Mail Tips',+ description: 'Reads pre-send mail tips for a set of recipients.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Checks recipients before sending and reports automatic replies or out-of-office messages, full mailboxes, maximum accepted message size, delivery restrictions, moderation and whether the recipient is external. Use this ahead of Send Email when a message is important or goes outside the organisation. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ emailAddresses: Property.Array({+ displayName: 'Recipient Email Addresses',+ description: 'Addresses to check. Up to 100 recipients per call.',+ required: true,+ }),+ },+ outputSchema: outlookGetMailTipsActionOutputSchema,+ async run(context) {+ const emailAddresses = context.propsValue.emailAddresses as string[];++ if (emailAddresses.length === 0) {+ throw new Error('Reading Outlook mail tips failed: no recipient addresses were supplied.');+ }++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const response = await client.api(`${prefix}/getMailTips`).post({+ EmailAddresses: emailAddresses,+ MailTipsOptions: mailTipsOptions,+ });++ const mailTips = (response?.['value'] ?? []) as Array<Record<string, unknown>>;++ return {+ mailTips,+ count: mailTips.length,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Reading Outlook mail tips' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-message-attachment.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-message-attachment.tsnew file mode 100644index 00000000000..68947fe7f69--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-message-attachment.ts@@ -0,0 +1,67 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookGetMessageAttachmentActionOutputSchema } from '../output-schemas';++export const outlookGetMessageAttachmentAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_get_message_attachment',+ classification: 'READ',+ displayName: 'Get Message Attachment',+ description: 'Reads the metadata of one attachment.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns the metadata of a single attachment (name, content type, size, inline flag and attachment kind) without transferring the file bytes. Use Download Message Attachment when the file content itself is needed, and List Message Attachments to discover attachment IDs. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ attachmentId: Property.ShortText({+ displayName: 'Attachment ID',+ description:+ 'Attachment ID from List Message Attachments. Attachment IDs are only valid inside their own message.',+ required: true,+ }),+ },+ outputSchema: outlookGetMessageAttachmentActionOutputSchema,+ async run(context) {+ const { messageId, attachmentId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const attachment = await client+ .api(+ `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(+ messageId,+ )}/attachments/${outlookAtomicCommon.encodeGraphId(attachmentId)}?$select=${+ outlookAtomicCommon.attachmentSelect+ }`,+ )+ .get();++ return {+ messageId,+ id: attachment?.['id'] ?? null,+ name: attachment?.['name'] ?? null,+ contentType: attachment?.['contentType'] ?? null,+ size: attachment?.['size'] ?? null,+ isInline: attachment?.['isInline'] ?? null,+ lastModifiedDateTime: attachment?.['lastModifiedDateTime'] ?? null,+ attachmentType: attachment?.['@odata.type'] ?? null,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Reading the Outlook message attachment',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-message-mime.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-message-mime.tsnew file mode 100644index 00000000000..69eae27a0ef--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-message-mime.ts@@ -0,0 +1,62 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ResponseType } from '@microsoft/microsoft-graph-client';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookGetMessageMimeActionOutputSchema } from '../output-schemas';++export const outlookGetMessageMimeAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_get_message_mime',+ classification: 'READ',+ displayName: 'Get Message MIME Content',+ description: 'Downloads the raw MIME (RFC-822) content of a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Stores the raw RFC-822 MIME source of one Outlook message, including full internet headers, as a byte-exact .eml file and returns that file plus its size. The content is not returned inline, because MIME can carry 8-bit and non-UTF-8 bytes that no text field round-trips; read the file when you need the headers. Use this for archival or forensic inspection; use Get Message when the parsed fields are enough. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ },+ outputSchema: outlookGetMessageMimeActionOutputSchema,+ async run(context) {+ const { messageId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const bytes = await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/$value`)+ .responseType(ResponseType.ARRAYBUFFER)+ .get();++ const buffer = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes);+ const fileName = 'message.eml';++ const file = await context.files.write({+ fileName,+ data: buffer,+ });++ return {+ messageId,+ fileName,+ contentType: 'message/rfc822',+ size: buffer.length,+ file,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Downloading the Outlook message MIME content',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-message.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-message.tsnew file mode 100644index 00000000000..67735f62e2b--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-message.ts@@ -0,0 +1,42 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookMessageActionOutputSchema } from '../output-schemas';++export const outlookGetMessageAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_get_message',+ classification: 'READ',+ displayName: 'Get Message',+ description: 'Retrieves a single message by its ID.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Reads one Outlook message by ID and returns its headers, plain-text body and metadata. Use this after List Messages or Search Messages to inspect a specific email; use Get Message MIME Content when you need the raw RFC-822 source. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ },+ outputSchema: outlookMessageActionOutputSchema,+ async run(context) {+ const { messageId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ return await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}`)+ .headers(outlookAtomicCommon.textBodyHeaders)+ .get();+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Reading the Outlook message' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-my-profile.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-my-profile.tsnew file mode 100644index 00000000000..124ee2d161d--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-my-profile.ts@@ -0,0 +1,49 @@+import { createAction } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookGetMyProfileActionOutputSchema } from '../output-schemas';++export const outlookGetMyProfileAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_get_my_profile',+ classification: 'READ',+ displayName: 'Get My Profile',+ description: 'Reads the identity of the connected account.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns the identity behind the connection: display name, primary email address and user principal name. Use this to learn your own address before composing mail, filtering a thread or deciding whether a sender is you. On app-only connections it reports the configured mailbox without calling Microsoft Graph, because reading another user profile would need a directory permission this piece does not request. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {},+ outputSchema: outlookGetMyProfileActionOutputSchema,+ async run(context) {+ if (outlookAtomicCommon.isAppOnlyConnection(context.auth)) {+ const mailbox = outlookAtomicCommon.getConfiguredMailbox(context.auth);+ return {+ id: null,+ displayName: null,+ mail: mailbox,+ userPrincipalName: mailbox,+ source: 'connection-mailbox',+ };+ }++ const client = outlookCommon.createClient(context.auth);++ try {+ const profile = await client.api('/me?$select=id,displayName,mail,userPrincipalName').get();++ return {+ id: profile?.['id'] ?? null,+ displayName: profile?.['displayName'] ?? null,+ mail: profile?.['mail'] ?? null,+ userPrincipalName: profile?.['userPrincipalName'] ?? null,+ source: 'graph',+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Reading the Outlook profile' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-supported-time-zones.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-supported-time-zones.tsnew file mode 100644index 00000000000..10b7d50f939--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-get-supported-time-zones.ts@@ -0,0 +1,50 @@+import { createAction } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookGetSupportedTimeZonesActionOutputSchema } from '../output-schemas';++export const outlookGetSupportedTimeZonesAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_get_supported_time_zones',+ classification: 'READ',+ displayName: 'Get Supported Time Zones',+ description: 'Lists the time zones Outlook accepts for this account.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists the time zone names Outlook accepts, so a time zone string can be validated before it is used elsewhere. Works on delegated connections only: Microsoft exposes no application permission for it, so app-only connections are rejected with an explanatory error. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {},+ outputSchema: outlookGetSupportedTimeZonesActionOutputSchema,+ async run(context) {+ if (outlookAtomicCommon.isAppOnlyConnection(context.auth)) {+ throw new Error(+ 'Listing the supported time zones is available on delegated Outlook connections only. Microsoft Graph exposes no application permission for this endpoint, so an app-only connection with a configured mailbox cannot call it.',+ );+ }++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const response: PageCollection = await client+ .api(`${prefix}/outlook/supportedTimeZones`)+ .get();++ const timeZones = (response.value ?? []) as Array<Record<string, unknown>>;++ return {+ timeZones,+ count: timeZones.length,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Listing the supported Outlook time zones',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-child-mail-folders.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-child-mail-folders.tsnew file mode 100644index 00000000000..f60aa8dd17a--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-child-mail-folders.ts@@ -0,0 +1,71 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { MailFolder } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookListChildMailFoldersActionOutputSchema } from '../output-schemas';++export const outlookListChildMailFoldersAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_list_child_mail_folders',+ classification: 'SEARCH',+ displayName: 'List Child Mail Folders',+ description: 'Lists the sub-folders of one mail folder.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists the direct sub-folders of a given mail folder, including hidden ones, so nested hierarchies can be walked one level at a time. Use List Mail Folders for the top level; a child folder ID works anywhere a folder ID is accepted. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ folderId: Property.ShortText({+ displayName: 'Parent Folder ID',+ description: outlookAtomicCommon.wellKnownFolderHint,+ required: true,+ defaultValue: 'inbox',+ }),+ maxResults: Property.Number({+ displayName: 'Max Results',+ description: 'Maximum number of folders to return (1-100).',+ required: false,+ defaultValue: 50,+ }),+ },+ outputSchema: outlookListChildMailFoldersActionOutputSchema,+ async run(context) {+ const { folderId, maxResults } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const top = Math.min(Math.max(maxResults ?? 50, 1), 100);++ try {+ const response: PageCollection = await client+ .api(+ `${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(+ folderId,+ )}/childFolders?includeHiddenFolders=true&$select=${+ outlookAtomicCommon.mailFolderSelect+ }&$top=${top}`,+ )+ .get();++ const folders = (response.value ?? []) as MailFolder[];+ const nextLink = response['@odata.nextLink'] as string | undefined;++ return {+ parentFolderId: folderId,+ folders,+ count: folders.length,+ hasMore: !!nextLink,+ nextLink: nextLink ?? null,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Listing the Outlook child mail folders',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-focused-inbox-overrides.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-focused-inbox-overrides.tsnew file mode 100644index 00000000000..165d7ef2f96--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-focused-inbox-overrides.ts@@ -0,0 +1,44 @@+import { createAction } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookListFocusedInboxOverridesActionOutputSchema } from '../output-schemas';++export const outlookListFocusedInboxOverridesAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_list_focused_inbox_overrides',+ classification: 'SEARCH',+ displayName: 'List Focused Inbox Overrides',+ description: 'Lists the Focused Inbox sender overrides of the mailbox.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists the Focused Inbox overrides that force mail from specific senders into the Focused or Other tab, with the override ID for each sender. Run this first: Update Focused Inbox Override and Delete Focused Inbox Override both need an ID that only this action returns. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {},+ outputSchema: outlookListFocusedInboxOverridesActionOutputSchema,+ async run(context) {+ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const response: PageCollection = await client+ .api(`${prefix}/inferenceClassification/overrides`)+ .get();++ const overrides = (response.value ?? []) as Array<Record<string, unknown>>;++ return {+ overrides,+ count: overrides.length,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Listing the Focused Inbox overrides',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-mail-folders-delta.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-mail-folders-delta.tsnew file mode 100644index 00000000000..fdf2ff55779--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-mail-folders-delta.ts@@ -0,0 +1,68 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { MailFolder } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookListMailFoldersDeltaActionOutputSchema } from '../output-schemas';++export const outlookListMailFoldersDeltaAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_list_mail_folders_delta',+ classification: 'SEARCH',+ displayName: 'List Folder Changes (Delta)',+ description: 'Tracks created, renamed and deleted mail folders.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns the mail folders created, renamed or removed since a previous delta link, plus a fresh delta link for the next call. Use this to keep a folder tree in sync instead of re-listing it; it pairs with List Message Changes (Delta) for messages. The delta link must be one this action returned on the same connection: any other URL is rejected instead of being followed. Each change carries a removed flag: when it is true the folder was deleted and only its id and removedReason are meaningful. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ deltaLink: Property.ShortText({+ displayName: 'Delta Link',+ description: `The deltaLink returned by a previous run. Leave empty to start a new sync from the current folder tree. ${outlookAtomicCommon.deltaLinkHint}`,+ required: false,+ }),+ },+ outputSchema: outlookListMailFoldersDeltaActionOutputSchema,+ async run(context) {+ const { deltaLink } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const operation = 'Listing the Outlook mail folder changes';+ const expectedPath = `${prefix}/mailFolders/delta`;+ const url = deltaLink+ ? outlookAtomicCommon.resolveDeltaUrl({+ auth: context.auth,+ deltaLink,+ expectedPath,+ operation,+ })+ : expectedPath;++ try {+ const response: PageCollection = await client+ .api(url)+ .headers({ Prefer: 'odata.maxpagesize=50' })+ .get();++ const changes = ((response.value ?? []) as MailFolder[]).map((change) =>+ outlookAtomicCommon.withDeltaRemoval(change),+ );+ const nextLink = response['@odata.nextLink'] as string | undefined;+ const nextDeltaLink = response['@odata.deltaLink'] as string | undefined;++ return {+ changes,+ count: changes.length,+ hasMore: !!nextLink,+ nextLink: nextLink ?? null,+ deltaLink: nextDeltaLink ?? null,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-mail-folders.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-mail-folders.tsnew file mode 100644index 00000000000..e1a347abe4d--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-mail-folders.ts@@ -0,0 +1,57 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { MailFolder } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookListMailFoldersActionOutputSchema } from '../output-schemas';++export const outlookListMailFoldersAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_list_mail_folders',+ classification: 'SEARCH',+ displayName: 'List Mail Folders',+ description: 'Lists the top-level mail folders of the mailbox.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists the top-level mail folders with their IDs, display names and item counts, including hidden folders. Use this to resolve a folder ID before moving, copying or listing messages; use List Child Mail Folders to walk deeper into the tree. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ maxResults: Property.Number({+ displayName: 'Max Results',+ description: 'Maximum number of folders to return (1-100).',+ required: false,+ defaultValue: 50,+ }),+ },+ outputSchema: outlookListMailFoldersActionOutputSchema,+ async run(context) {+ const { maxResults } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const top = Math.min(Math.max(maxResults ?? 50, 1), 100);++ try {+ const response: PageCollection = await client+ .api(+ `${prefix}/mailFolders?includeHiddenFolders=true&$select=${outlookAtomicCommon.mailFolderSelect}&$top=${top}`,+ )+ .get();++ const folders = (response.value ?? []) as MailFolder[];+ const nextLink = response['@odata.nextLink'] as string | undefined;++ return {+ folders,+ count: folders.length,+ hasMore: !!nextLink,+ nextLink: nextLink ?? null,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Listing the Outlook mail folders' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-message-attachments.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-message-attachments.tsnew file mode 100644index 00000000000..de3b4deaf4c--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-message-attachments.ts@@ -0,0 +1,65 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookListMessageAttachmentsActionOutputSchema } from '../output-schemas';++export const outlookListMessageAttachmentsAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_list_message_attachments',+ classification: 'SEARCH',+ displayName: 'List Message Attachments',+ description: 'Lists the attachments of a message without downloading them.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists every attachment on one message with its ID, name, content type, size and kind, without transferring any file bytes. Use this first to pick an attachment ID for Download Message Attachment or Get Message Attachment. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ },+ outputSchema: outlookListMessageAttachmentsActionOutputSchema,+ async run(context) {+ const { messageId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const response: PageCollection = await client+ .api(+ `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(+ messageId,+ )}/attachments?$select=${outlookAtomicCommon.attachmentSelect}`,+ )+ .get();++ const attachments = (response.value ?? []) as Array<Record<string, unknown>>;++ return {+ messageId,+ attachments: attachments.map((attachment) => ({+ id: attachment['id'] ?? null,+ name: attachment['name'] ?? null,+ contentType: attachment['contentType'] ?? null,+ size: attachment['size'] ?? null,+ isInline: attachment['isInline'] ?? null,+ lastModifiedDateTime: attachment['lastModifiedDateTime'] ?? null,+ attachmentType: attachment['@odata.type'] ?? null,+ })),+ count: attachments.length,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Listing the Outlook message attachments',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-messages-delta.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-messages-delta.tsnew file mode 100644index 00000000000..92984a1f99e--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-messages-delta.ts@@ -0,0 +1,74 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { Message } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookListMessagesDeltaActionOutputSchema } from '../output-schemas';++export const outlookListMessagesDeltaAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_list_messages_delta',+ classification: 'SEARCH',+ displayName: 'List Message Changes (Delta)',+ description: 'Tracks created, updated and deleted messages in a folder.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns the messages added, changed or removed in one mail folder since a previous delta link, plus a fresh delta link for the next call. Use this for incremental sync instead of re-listing a folder; a first call without a delta link returns the current contents. The delta link must be one this action returned on the same connection: any other URL is rejected instead of being followed. Each change carries a removed flag: when it is true the item was deleted and only its id and removedReason are meaningful. Delta payloads omit message bodies and attachments, so follow up with Get Message for full content. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ folderId: Property.ShortText({+ displayName: 'Folder ID',+ description: `Folder to track. ${outlookAtomicCommon.wellKnownFolderHint}`,+ required: true,+ defaultValue: 'inbox',+ }),+ deltaLink: Property.ShortText({+ displayName: 'Delta Link',+ description: `The deltaLink returned by a previous run. Leave empty to start a new sync from the current folder state. ${outlookAtomicCommon.deltaLinkHint}`,+ required: false,+ }),+ },+ outputSchema: outlookListMessagesDeltaActionOutputSchema,+ async run(context) {+ const { folderId, deltaLink } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ const operation = 'Listing Outlook message changes';+ const url = deltaLink+ ? outlookAtomicCommon.resolveDeltaUrl({+ auth: context.auth,+ deltaLink,+ expectedPath: `${prefix}/mailFolders/*/messages/delta`,+ operation,+ })+ : `${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(folderId)}/messages/delta?$select=${outlookAtomicCommon.messageSelect}`;++ try {+ const response: PageCollection = await client+ .api(url)+ .headers({ Prefer: 'odata.maxpagesize=50' })+ .get();++ const changes = ((response.value ?? []) as Message[]).map((change) =>+ outlookAtomicCommon.withDeltaRemoval(change),+ );+ const nextLink = response['@odata.nextLink'] as string | undefined;+ const nextDeltaLink = response['@odata.deltaLink'] as string | undefined;++ return {+ changes,+ count: changes.length,+ hasMore: !!nextLink,+ nextLink: nextLink ?? null,+ deltaLink: nextDeltaLink ?? null,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-messages.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-messages.tsnew file mode 100644index 00000000000..a4b1a7d4f2a--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-list-messages.ts@@ -0,0 +1,87 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { Message } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookListMessagesActionOutputSchema } from '../output-schemas';++export const outlookListMessagesAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_list_messages',+ classification: 'SEARCH',+ displayName: 'List Messages',+ description: 'Lists messages from the mailbox or a single mail folder.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Enumerates Outlook messages, optionally scoped to one mail folder and narrowed by an OData $filter expression, and returns their IDs and headers. Use this to discover message IDs for other actions; use Search Messages instead when you only have free-text keywords. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ folderId: Property.ShortText({+ displayName: 'Folder ID',+ description: `Limit the listing to one folder. ${outlookAtomicCommon.wellKnownFolderHint} Leave empty to list the whole mailbox.`,+ required: false,+ }),+ filter: Property.ShortText({+ displayName: 'Filter',+ description:+ 'Optional OData $filter expression, for example: isRead eq false, or receivedDateTime ge 2024-01-01T00:00:00Z.',+ required: false,+ }),+ maxResults: Property.Number({+ displayName: 'Max Results',+ description: 'Maximum number of messages to return (1-100).',+ required: false,+ defaultValue: 25,+ }),+ skip: Property.Number({+ displayName: 'Skip',+ description: 'Number of messages to skip before returning results, for paging.',+ required: false,+ }),+ },+ outputSchema: outlookListMessagesActionOutputSchema,+ async run(context) {+ const { folderId, filter, maxResults, skip } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const basePath = folderId+ ? `${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(folderId)}/messages`+ : `${prefix}/messages`;++ const top = Math.min(Math.max(maxResults ?? 25, 1), 100);+ const queryParams = [`$select=${outlookAtomicCommon.messageSelect}`, `$top=${top}`];++ if (filter) {+ queryParams.push(`$filter=${encodeURIComponent(filter)}`);+ } else {+ queryParams.push('$orderby=receivedDateTime%20desc');+ }++ if (skip !== undefined && skip > 0) {+ queryParams.push(`$skip=${Math.floor(skip)}`);+ }++ try {+ const response: PageCollection = await client+ .api(`${basePath}?${queryParams.join('&')}`)+ .headers(outlookAtomicCommon.textBodyHeaders)+ .get();++ const messages = (response.value ?? []) as Message[];+ const nextLink = response['@odata.nextLink'] as string | undefined;++ return {+ messages,+ count: messages.length,+ hasMore: !!nextLink,+ nextLink: nextLink ?? null,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Listing Outlook messages' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-move-mail-folder.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-move-mail-folder.tsnew file mode 100644index 00000000000..16a14c474df--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-move-mail-folder.ts@@ -0,0 +1,58 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { MailFolder } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookMoveMailFolderActionOutputSchema } from '../output-schemas';++export const outlookMoveMailFolderAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_move_mail_folder',+ classification: 'WRITE',+ displayName: 'Move Mail Folder',+ description: 'Moves a mail folder under another folder.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Reparents a mail folder, moving it with its messages and sub-folders under a different destination folder. Use Copy Mail Folder to duplicate instead of relocating, and Rename Mail Folder to change only its name. The move issues the folder a new ID: carry newFolderId forward into later steps, not the folderId that was passed in. Not idempotent: once moved, the same call repeated against the old parent no longer applies.',+ idempotent: false,+ },+ props: {+ folderId: Property.ShortText({+ displayName: 'Folder ID',+ description: outlookAtomicCommon.wellKnownFolderHint,+ required: true,+ }),+ destinationFolderId: Property.ShortText({+ displayName: 'Destination Folder ID',+ description: `New parent folder. ${outlookAtomicCommon.wellKnownFolderHint}`,+ required: true,+ }),+ },+ outputSchema: outlookMoveMailFolderActionOutputSchema,+ async run(context) {+ const { folderId, destinationFolderId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const moved: MailFolder = await client+ .api(`${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(folderId)}/move`)+ .post({ destinationId: destinationFolderId });++ return {+ success: true,+ folderId,+ newFolderId: moved?.id ?? null,+ destinationFolderId,+ folder: moved,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Moving the Outlook mail folder',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-move-message.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-move-message.tsnew file mode 100644index 00000000000..0c14a575a3a--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-move-message.ts@@ -0,0 +1,55 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { Message } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookMoveMessageActionOutputSchema } from '../output-schemas';++export const outlookMoveMessageAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_move_message',+ classification: 'WRITE',+ displayName: 'Move Message',+ description: 'Moves a message to another mail folder.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Moves one message into another mail folder and returns the moved copy. The move mints a NEW message ID: the original ID stops resolving, so use the returned newMessageId for any follow-up step. Use Copy Message to leave the original in place, or Batch Move Messages for many messages. Not idempotent: a retry with the old ID fails.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ destinationFolderId: Property.ShortText({+ displayName: 'Destination Folder ID',+ description: outlookAtomicCommon.wellKnownFolderHint,+ required: true,+ }),+ },+ outputSchema: outlookMoveMessageActionOutputSchema,+ async run(context) {+ const { messageId, destinationFolderId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ const moved: Message = await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/move`)+ .post({ destinationId: destinationFolderId });++ return {+ success: true,+ previousMessageId: messageId,+ newMessageId: moved?.id ?? null,+ destinationFolderId,+ message: moved,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Moving the Outlook message' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-permanently-delete-message.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-permanently-delete-message.tsnew file mode 100644index 00000000000..9fca74de23a--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-permanently-delete-message.ts@@ -0,0 +1,103 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';++export const outlookPermanentlyDeleteMessageAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_permanently_delete_message',+ classification: 'DESTRUCTIVE',+ displayName: 'Permanently Delete Message',+ description: 'Permanently deletes a message so it cannot be recovered.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Permanently removes one message from the mailbox with no way to recover it, bypassing Deleted Items. Prefer Delete Message (to Deleted Items) in every case where recovery might be wanted; only use this when the caller explicitly asked for unrecoverable deletion. Unavailable on US Government DoD and 21Vianet clouds. Not idempotent: a retry with the same ID fails.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ confirm: Property.Checkbox({+ displayName: 'Confirm Permanent Deletion',+ description: 'Must be enabled. The message cannot be recovered afterwards.',+ required: true,+ defaultValue: false,+ }),+ },+ async run(context) {+ const { messageId, confirm } = context.propsValue;++ if (!confirm) {+ throw new Error(+ 'Permanently deleting the Outlook message was refused: enable Confirm Permanent Deletion to proceed, or use Delete Message (to Deleted Items) instead.',+ );+ }++ if (outlookAtomicCommon.isGovernmentCloud(context.auth)) {+ throw new Error(+ 'Permanently deleting the Outlook message is not available on the US Government cloud. Use Delete Message (to Deleted Items) instead.',+ );+ }++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const encodedMessageId = outlookAtomicCommon.encodeGraphId(messageId);++ try {+ await client.api(`${prefix}/messages/${encodedMessageId}/permanentDelete`).post({});++ return {+ success: true,+ message: 'Message permanently deleted.',+ messageId,+ };+ } catch (error) {+ const retryableAsUserPath =+ prefix === '/me' && outlookAtomicCommon.isUnsupportedMePathError(error);++ if (!retryableAsUserPath) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Permanently deleting the Outlook message',+ });+ }++ try {+ const profile = await client.api('/me?$select=id').get();+ const userId = profile?.['id'] as string | undefined;++ if (!userId) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Permanently deleting the Outlook message',+ });+ }++ await client+ .api(+ `/users/${outlookAtomicCommon.encodeGraphId(+ userId,+ )}/messages/${encodedMessageId}/permanentDelete`,+ )+ .post({});++ return {+ success: true,+ message: 'Message permanently deleted.',+ messageId,+ };+ } catch (fallbackError) {+ throw outlookAtomicCommon.graphError({+ error: fallbackError,+ operation: `Permanently deleting the Outlook message (retried against /users/{id} after the /me path was rejected with: ${outlookAtomicCommon.graphErrorDetail(+ error,+ )})`,+ });+ }+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-remove-message-categories.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-remove-message-categories.tsnew file mode 100644index 00000000000..a6b14e750f4--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-remove-message-categories.ts@@ -0,0 +1,56 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookMessageActionOutputSchema } from '../output-schemas';++export const outlookRemoveMessageCategoriesAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_remove_message_categories',+ classification: 'WRITE',+ displayName: 'Remove Categories from Message',+ description: 'Removes categories (labels) from a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Removes one or more Outlook categories from a message while leaving its other categories intact. Use Add Categories to Message for the inverse, and Update Message when other fields change too. Idempotent: removing a category the message does not have changes nothing.',+ idempotent: true,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ categories: Property.Array({+ displayName: 'Categories to Remove',+ description: 'Category names to remove from the message.',+ required: true,+ }),+ },+ outputSchema: outlookMessageActionOutputSchema,+ async run(context) {+ const { messageId } = context.propsValue;+ const categories = context.propsValue.categories as string[];++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const path = `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}`;++ try {+ const current = await client.api(`${path}?$select=id,categories`).get();+ const existing = (current?.['categories'] ?? []) as string[];+ const remaining = existing.filter((category) => !categories.includes(category));++ return await client+ .api(path)+ .headers(outlookAtomicCommon.textBodyHeaders)+ .patch({ categories: remaining });+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Removing categories from the Outlook message',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-reply-all-to-message.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-reply-all-to-message.tsnew file mode 100644index 00000000000..56d92ffb0ba--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-reply-all-to-message.ts@@ -0,0 +1,55 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookReplyAllToMessageActionOutputSchema } from '../output-schemas';++export const outlookReplyAllToMessageAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_reply_all_to_message',+ classification: 'WRITE',+ displayName: 'Reply All to Message',+ description: 'Replies to the sender and all recipients of a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Sends a reply to the sender and every other recipient of an existing message. Use Reply to Message to answer the sender only, or Create Reply-All Draft when the reply must be reviewed first. Not idempotent: each call sends another reply to everyone on the thread.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ comment: Property.LongText({+ displayName: 'Reply Text',+ description: 'Text added above the quoted original message.',+ required: true,+ }),+ },+ outputSchema: outlookReplyAllToMessageActionOutputSchema,+ async run(context) {+ const { messageId, comment } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/replyAll`)+ .post({ comment });++ return {+ success: true,+ message: 'Reply-all sent successfully.',+ messageId,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Replying to all recipients of the Outlook message',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-reply-to-message.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-reply-to-message.tsnew file mode 100644index 00000000000..de0e6a36c6b--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-reply-to-message.ts@@ -0,0 +1,65 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { Message } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookReplyToMessageActionOutputSchema } from '../output-schemas';++export const outlookReplyToMessageAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_reply_to_message',+ classification: 'WRITE',+ displayName: 'Reply to Message',+ description: 'Replies to the sender of a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Sends a reply to the sender of an existing message, quoting the original thread. Use Reply All to Message to include every original recipient, or Create Reply Draft when the reply must be reviewed before sending. Not idempotent: each call sends another reply.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ comment: Property.LongText({+ displayName: 'Reply Text',+ description: 'Text added above the quoted original message.',+ required: true,+ }),+ ccRecipients: Property.Array({+ displayName: 'Additional CC Email(s)',+ required: false,+ }),+ },+ outputSchema: outlookReplyToMessageActionOutputSchema,+ async run(context) {+ const { messageId, comment } = context.propsValue;+ const ccRecipients = (context.propsValue.ccRecipients ?? []) as string[];++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ const payload: { comment: string; message?: Message } = { comment };+ if (ccRecipients.length > 0) {+ payload.message = {+ ccRecipients: ccRecipients.map((mail) => ({ emailAddress: { address: mail } })),+ };+ }++ try {+ await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/reply`)+ .post(payload);++ return {+ success: true,+ message: 'Reply sent successfully.',+ messageId,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Replying to the Outlook message' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-search-messages.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-search-messages.tsnew file mode 100644index 00000000000..9709fcee5fd--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-search-messages.ts@@ -0,0 +1,82 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { PageCollection } from '@microsoft/microsoft-graph-client';+import { Message } from '@microsoft/microsoft-graph-types';+import dayjs from 'dayjs';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookSearchMessagesActionOutputSchema } from '../output-schemas';++export const outlookSearchMessagesAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_search_messages',+ classification: 'SEARCH',+ displayName: 'Search Messages',+ description: 'Searches messages with a full-text query.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Runs a full-text Outlook search (KQL terms such as from:[email protected], subject:invoice or hasAttachments:true), optionally inside one folder, and returns matching messages newest first. Pick this when you have keywords; use List Messages when you need an exact OData filter or paging. Search cannot be combined with filters or server-side sorting, and is unreliable on personal Microsoft accounts. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ searchQuery: Property.ShortText({+ displayName: 'Search Query',+ description:+ 'Keywords or KQL terms to match, for example: from:[email protected], subject:urgent, hasAttachments:true.',+ required: true,+ }),+ folderId: Property.ShortText({+ displayName: 'Folder ID',+ description: `Search inside one folder only. ${outlookAtomicCommon.wellKnownFolderHint} Leave empty to search the whole mailbox.`,+ required: false,+ }),+ maxResults: Property.Number({+ displayName: 'Max Results',+ description: 'Maximum number of results to return (1-1000).',+ required: false,+ defaultValue: 25,+ }),+ },+ outputSchema: outlookSearchMessagesActionOutputSchema,+ async run(context) {+ const { searchQuery, folderId, maxResults } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const basePath = folderId+ ? `${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(folderId)}/messages`+ : `${prefix}/messages`;++ const top = Math.min(Math.max(maxResults ?? 25, 1), 1000);+ const url = `${basePath}?$search=${encodeURIComponent(`"${searchQuery}"`)}&$top=${top}`;++ try {+ const response: PageCollection = await client+ .api(url)+ .headers({+ ConsistencyLevel: 'eventual',+ ...outlookAtomicCommon.textBodyHeaders,+ })+ .get();++ const messages = (response.value ?? []) as Message[];+ messages.sort(+ (first, second) =>+ dayjs(second.receivedDateTime).valueOf() - dayjs(first.receivedDateTime).valueOf(),+ );++ const nextLink = response['@odata.nextLink'] as string | undefined;++ return {+ found: messages.length > 0,+ messages,+ count: messages.length,+ hasMore: !!nextLink,+ nextLink: nextLink ?? null,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Searching Outlook messages' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-send-draft.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-send-draft.tsnew file mode 100644index 00000000000..92183e24255--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-send-draft.ts@@ -0,0 +1,48 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookSendDraftActionOutputSchema } from '../output-schemas';++export const outlookSendDraftAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_send_draft',+ classification: 'WRITE',+ displayName: 'Send Draft',+ description: 'Sends an existing draft message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Sends a draft that already exists in the mailbox, identified by its message ID. Use this after Create Draft, Create Reply Draft, Create Reply-All Draft or Create Forward Draft. Not idempotent: the draft stops existing once sent, so a repeat call with the same ID fails.',+ idempotent: false,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Draft Message ID',+ description:+ 'ID of the draft to send. Obtain it from Create Draft or one of the Create ... Draft actions.',+ required: true,+ }),+ },+ outputSchema: outlookSendDraftActionOutputSchema,+ async run(context) {+ const { messageId } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}/send`)+ .post({});++ return {+ success: true,+ message: 'Draft sent successfully.',+ messageId,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Sending the Outlook draft' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-send-email.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-send-email.tsnew file mode 100644index 00000000000..916b919e3aa--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-send-email.ts@@ -0,0 +1,116 @@+import { ApFile, createAction, Property } from '@activepieces/pieces-framework';+import { BodyType, Message } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookSendEmailActionOutputSchema } from '../output-schemas';++export const outlookSendEmailAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_send_email',+ classification: 'WRITE',+ displayName: 'Send Email',+ description: 'Composes and sends a new email.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Composes and immediately sends a brand new email from the connected Outlook mailbox, with optional CC, BCC and attachments, and saves a copy in Sent Items. Use Reply to Message or Forward Message instead when responding to existing mail, and Create Draft when the message should be staged rather than sent. Not idempotent: every call dispatches another email.',+ idempotent: false,+ },+ props: {+ recipients: Property.Array({+ displayName: 'To Email(s)',+ description: 'Email addresses of the primary recipients.',+ required: true,+ }),+ ccRecipients: Property.Array({+ displayName: 'CC Email(s)',+ required: false,+ }),+ bccRecipients: Property.Array({+ displayName: 'BCC Email(s)',+ required: false,+ }),+ subject: Property.ShortText({+ displayName: 'Subject',+ required: true,+ }),+ bodyFormat: Property.StaticDropdown({+ displayName: 'Body Format',+ required: true,+ defaultValue: 'text',+ options: {+ disabled: false,+ options: [+ { label: 'HTML', value: 'html' },+ { label: 'Text', value: 'text' },+ ],+ },+ }),+ body: Property.LongText({+ displayName: 'Body',+ required: true,+ }),+ attachments: Property.Array({+ displayName: 'Attachments',+ description: 'Files to attach. Total message size must stay under 3 MB.',+ required: false,+ properties: {+ file: Property.File({+ displayName: 'File',+ required: true,+ }),+ fileName: Property.ShortText({+ displayName: 'File Name',+ required: false,+ }),+ },+ }),+ },+ outputSchema: outlookSendEmailActionOutputSchema,+ async run(context) {+ const recipients = context.propsValue.recipients as string[];+ const ccRecipients = (context.propsValue.ccRecipients ?? []) as string[];+ const bccRecipients = (context.propsValue.bccRecipients ?? []) as string[];+ const attachments = (context.propsValue.attachments ?? []) as Array<{+ file: ApFile;+ fileName: string;+ }>;++ const { subject, body, bodyFormat } = context.propsValue;++ const mailPayload: Message = {+ subject,+ body: {+ content: body,+ contentType: bodyFormat as BodyType,+ },+ toRecipients: recipients.map((mail) => ({ emailAddress: { address: mail } })),+ ccRecipients: ccRecipients.map((mail) => ({ emailAddress: { address: mail } })),+ bccRecipients: bccRecipients.map((mail) => ({ emailAddress: { address: mail } })),+ attachments: attachments.map((attachment) => ({+ '@odata.type': '#microsoft.graph.fileAttachment',+ name: attachment.fileName || attachment.file.filename,+ contentBytes: attachment.file.base64,+ })),+ };++ const client = outlookCommon.createClient(context.auth);++ try {+ await client.api(`${outlookCommon.mailboxPrefix(context.auth)}/sendMail`).post({+ message: mailPayload,+ saveToSentItems: 'true',+ });++ return {+ success: true,+ message: 'Email sent successfully.',+ subject,+ recipients,+ };+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Sending the Outlook email' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-set-message-read-status.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-set-message-read-status.tsnew file mode 100644index 00000000000..7f2f2827527--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-set-message-read-status.ts@@ -0,0 +1,57 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookMessageActionOutputSchema } from '../output-schemas';++export const outlookSetMessageReadStatusAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_set_message_read_status',+ classification: 'WRITE',+ displayName: 'Mark Message Read / Unread',+ description: 'Marks a message as read or unread.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Sets only the read state of one message, leaving every other property untouched. Use this for the common mark-as-read step; use Update Message when other fields change too, or Batch Update Messages for many messages at once. Idempotent: re-applying the same state changes nothing.',+ idempotent: true,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ isRead: Property.StaticDropdown({+ displayName: 'Read State',+ required: true,+ defaultValue: 'true',+ options: {+ disabled: false,+ options: [+ { label: 'Mark as read', value: 'true' },+ { label: 'Mark as unread', value: 'false' },+ ],+ },+ }),+ },+ outputSchema: outlookMessageActionOutputSchema,+ async run(context) {+ const { messageId, isRead } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ return await client+ .api(`${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}`)+ .headers(outlookAtomicCommon.textBodyHeaders)+ .patch({ isRead: isRead === 'true' });+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Updating the read state of the Outlook message',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-update-focused-inbox-override.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-update-focused-inbox-override.tsnew file mode 100644index 00000000000..2b3002cf820--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-update-focused-inbox-override.ts@@ -0,0 +1,59 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookFocusedInboxOverrideActionOutputSchema } from '../output-schemas';++export const outlookUpdateFocusedInboxOverrideAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_update_focused_inbox_override',+ classification: 'WRITE',+ displayName: 'Update Focused Inbox Override',+ description: 'Changes the classification of a Focused Inbox override.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Switches an existing Focused Inbox override between the Focused and Other tabs. The classification is the only writable property, and the override ID comes from List Focused Inbox Overrides. Idempotent: applying the same classification again changes nothing.',+ idempotent: true,+ },+ props: {+ overrideId: Property.ShortText({+ displayName: 'Override ID',+ description: 'Override ID from List Focused Inbox Overrides.',+ required: true,+ }),+ classifyAs: Property.StaticDropdown({+ displayName: 'Classify As',+ required: true,+ options: {+ disabled: false,+ options: [+ { label: 'Focused', value: 'focused' },+ { label: 'Other', value: 'other' },+ ],+ },+ }),+ },+ outputSchema: outlookFocusedInboxOverrideActionOutputSchema,+ async run(context) {+ const { overrideId, classifyAs } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ return await client+ .api(+ `${prefix}/inferenceClassification/overrides/${outlookAtomicCommon.encodeGraphId(+ overrideId,+ )}`,+ )+ .patch({ classifyAs });+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Updating the Focused Inbox override',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-update-mail-folder.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-update-mail-folder.tsnew file mode 100644index 00000000000..4717c4a4861--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-update-mail-folder.ts@@ -0,0 +1,48 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookFullMailFolderActionOutputSchema } from '../output-schemas';++export const outlookUpdateMailFolderAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_update_mail_folder',+ classification: 'WRITE',+ displayName: 'Rename Mail Folder',+ description: 'Renames a mail folder.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Renames a mail folder. The display name is the only writable property of a folder, so use Move Mail Folder to change its parent and Create Mail Folder to add a new one. Idempotent: applying the same name again changes nothing.',+ idempotent: true,+ },+ props: {+ folderId: Property.ShortText({+ displayName: 'Folder ID',+ description: outlookAtomicCommon.wellKnownFolderHint,+ required: true,+ }),+ displayName: Property.ShortText({+ displayName: 'New Folder Name',+ required: true,+ }),+ },+ outputSchema: outlookFullMailFolderActionOutputSchema,+ async run(context) {+ const { folderId, displayName } = context.propsValue;++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);++ try {+ return await client+ .api(`${prefix}/mailFolders/${outlookAtomicCommon.encodeGraphId(folderId)}`)+ .patch({ displayName });+ } catch (error) {+ throw outlookAtomicCommon.graphError({+ error,+ operation: 'Renaming the Outlook mail folder',+ });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-update-message.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-update-message.tsnew file mode 100644index 00000000000..5edcec0ad28--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/outlook-update-message.ts@@ -0,0 +1,150 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { BodyType, FollowupFlagStatus, Importance, Message } from '@microsoft/microsoft-graph-types';+import { microsoftOutlookAuth } from '../common/auth';+import { outlookAtomicCommon } from '../common/atomic-common';+import { outlookCommon } from '../common/client';+import { outlookMessageActionOutputSchema } from '../output-schemas';++export const outlookUpdateMessageAction = createAction({+ auth: microsoftOutlookAuth,+ name: 'outlook_update_message',+ classification: 'WRITE',+ displayName: 'Update Message',+ description: 'Updates the writable properties of a message.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Updates one message in place: read state, flag state, importance and categories on any message, plus subject and body on a draft. Fields left empty are not sent, and categories are merged with the ones already on the message instead of replacing them. Use Mark Message Read / Unread for the read flag alone, or Batch Update Messages for many messages at once. Idempotent: re-applying the same values converges on the same state.',+ idempotent: true,+ },+ props: {+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: outlookAtomicCommon.messageIdHint,+ required: true,+ }),+ isRead: Property.StaticDropdown({+ displayName: 'Read State',+ description: 'Leave unset to keep the current read state.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Mark as read', value: 'true' },+ { label: 'Mark as unread', value: 'false' },+ ],+ },+ }),+ flagStatus: Property.StaticDropdown({+ displayName: 'Flag State',+ description: 'Leave unset to keep the current flag.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Flagged', value: 'flagged' },+ { label: 'Not flagged', value: 'notFlagged' },+ { label: 'Complete', value: 'complete' },+ ],+ },+ }),+ importance: Property.StaticDropdown({+ displayName: 'Importance',+ description: 'Leave unset to keep the current importance.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Low', value: 'low' },+ { label: 'Normal', value: 'normal' },+ { label: 'High', value: 'high' },+ ],+ },+ }),+ categoriesToAdd: Property.Array({+ displayName: 'Categories to Add',+ description: 'Category names to add, merged with the categories already on the message.',+ required: false,+ }),+ categoriesToRemove: Property.Array({+ displayName: 'Categories to Remove',+ description: 'Category names to remove from the message.',+ required: false,+ }),+ subject: Property.ShortText({+ displayName: 'Subject',+ description: 'Only writable while the message is still a draft.',+ required: false,+ }),+ body: Property.LongText({+ displayName: 'Body',+ description: 'Only writable while the message is still a draft.',+ required: false,+ }),+ bodyFormat: Property.StaticDropdown({+ displayName: 'Body Format',+ description: 'Format of the new body. Ignored when no body is supplied.',+ required: false,+ defaultValue: 'text',+ options: {+ disabled: false,+ options: [+ { label: 'HTML', value: 'html' },+ { label: 'Text', value: 'text' },+ ],+ },+ }),+ },+ outputSchema: outlookMessageActionOutputSchema,+ async run(context) {+ const { messageId, isRead, flagStatus, importance, subject, body, bodyFormat } =+ context.propsValue;+ const categoriesToAdd = (context.propsValue.categoriesToAdd ?? []) as string[];+ const categoriesToRemove = (context.propsValue.categoriesToRemove ?? []) as string[];++ const client = outlookCommon.createClient(context.auth);+ const prefix = outlookCommon.mailboxPrefix(context.auth);+ const path = `${prefix}/messages/${outlookAtomicCommon.encodeGraphId(messageId)}`;++ const payload: Message = {};++ if (isRead !== undefined) {+ payload.isRead = isRead === 'true';+ }+ if (flagStatus !== undefined) {+ payload.flag = { flagStatus: flagStatus as FollowupFlagStatus };+ }+ if (importance !== undefined) {+ payload.importance = importance as Importance;+ }+ if (subject !== undefined) {+ payload.subject = subject;+ }+ if (body !== undefined) {+ payload.body = { content: body, contentType: (bodyFormat ?? 'text') as BodyType };+ }++ const changesCategories = categoriesToAdd.length > 0 || categoriesToRemove.length > 0;++ if (Object.keys(payload).length === 0 && !changesCategories) {+ throw new Error(+ 'Updating the Outlook message failed: no fields were supplied, so there is nothing to change.',+ );+ }++ try {+ if (changesCategories) {+ const current = await client.api(`${path}?$select=id,categories`).get();+ const existing = (current?.['categories'] ?? []) as string[];+ const merged = [...new Set([...existing, ...categoriesToAdd])].filter(+ (category) => !categoriesToRemove.includes(category),+ );+ payload.categories = merged;+ }++ return await client.api(path).headers(outlookAtomicCommon.textBodyHeaders).patch(payload);+ } catch (error) {+ throw outlookAtomicCommon.graphError({ error, operation: 'Updating the Outlook message' });+ }+ },+});diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/remove-label-from-email.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/remove-label-from-email.tsindex efe826bed8b..ab1e99160e0 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/actions/remove-label-from-email.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/remove-label-from-email.ts@@ -10,7 +10,7 @@ export const removeLabelFromEmailAction = createAction({classification: 'WRITE',displayName: 'Remove Label from Email',description: 'Removes a category (label) from an email message.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Removes one or more Outlook categories (labels) from a specific message, leaving any other categories intact. Use this to untag or reclassify an email. Idempotent: re-running with the same categories yields the same final label set.', idempotent: true },outputSchema: messageActionOutputSchema,props: {diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/reply-email.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/reply-email.tsindex 19f7b1f7e1e..2557bb80def 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/actions/reply-email.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/reply-email.ts@@ -11,7 +11,7 @@ export const replyEmailAction = createAction({classification: 'WRITE',displayName: 'Reply to Email',description: 'Reply to an outlook email.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Replies to an existing Outlook message (identified by message ID), supporting added CC/BCC recipients and attachments. Set the Create Draft flag to stage the reply without sending; otherwise it is sent immediately. Not idempotent when sending: each call creates and dispatches a new reply.', idempotent: false },outputSchema: replyEmailActionOutputSchema,props: {diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/send-draft-email.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/send-draft-email.tsindex da207fa374d..0a1e90ddff3 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/actions/send-draft-email.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/send-draft-email.ts@@ -10,7 +10,7 @@ export const sendDraftEmailAction = createAction({classification: 'WRITE',displayName: 'Send Draft Email',description: 'Sends a draft email message.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Sends an existing draft email (identified by draft message ID) from the Outlook mailbox. Use this to dispatch a draft previously staged by Create Draft Email or a draft reply. Not idempotent: once sent the draft no longer exists, so re-running with the same ID will fail.', idempotent: false },outputSchema: sendDraftEmailActionOutputSchema,props: {diff --git a/packages/pieces/community/microsoft-outlook/src/lib/actions/send-email.ts b/packages/pieces/community/microsoft-outlook/src/lib/actions/send-email.tsindex 11c5233dd24..4e1d79d3462 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/actions/send-email.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/actions/send-email.ts@@ -10,7 +10,7 @@ export const sendEmailAction = createAction({classification: 'WRITE',displayName: 'Send Email',description: 'Sends an email using Microsoft Outlook.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Composes and sends a new email from the authenticated Outlook mailbox to the given recipients, with optional CC/BCC and file attachments. Use this to send a fresh message (not a reply or forward). Not idempotent: each call dispatches a new email and saves a copy to Sent Items.', idempotent: false },props: {recipients: Property.Array({diff --git a/packages/pieces/community/microsoft-outlook/src/lib/common/atomic-common.ts b/packages/pieces/community/microsoft-outlook/src/lib/common/atomic-common.tsnew file mode 100644index 00000000000..5b7017de822--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/common/atomic-common.ts@@ -0,0 +1,247 @@+import { OAuth2PropertyValue } from '@activepieces/pieces-framework';+import { getGraphBaseUrl, getMicrosoftCloudFromAuth } from './microsoft-cloud';++const textBodyHeaders: Record<string, string> = {+ Prefer: 'outlook.body-content-type="text"',+};++const messageSelect =+ 'id,subject,bodyPreview,from,sender,toRecipients,ccRecipients,bccRecipients,replyTo,receivedDateTime,sentDateTime,createdDateTime,lastModifiedDateTime,hasAttachments,isRead,isDraft,importance,categories,flag,webLink,parentFolderId,conversationId,internetMessageId';++const mailFolderSelect =+ 'id,displayName,parentFolderId,childFolderCount,unreadItemCount,totalItemCount,isHidden';++const attachmentSelect = 'id,name,contentType,size,isInline,lastModifiedDateTime';++const wellKnownFolderHint =+ 'Accepts a mail folder ID or a well-known name such as inbox, drafts, sentitems, deleteditems, archive or junkemail.';++const deltaLinkHint =+ 'It must be a delta link returned by this action on this connection; links pointing at another mailbox or endpoint are rejected.';++const messageIdHint =+ 'Outlook message ID. Resolve one with List Messages, Search Messages or Get Message.';++function getConfiguredMailbox(auth: OAuth2PropertyValue): string {+ return ((auth.props?.['mailbox'] as string | undefined) ?? '').trim();+}++function isAppOnlyConnection(auth: OAuth2PropertyValue): boolean {+ return getConfiguredMailbox(auth).length > 0;+}++function encodeGraphId(id: string): string {+ return encodeURIComponent(id.trim());+}++function isGovernmentCloud(auth: OAuth2PropertyValue): boolean {+ return ((auth.props?.['cloud'] as string | undefined) ?? '').includes('.us');+}++function graphStatusCode(error: unknown): number | undefined {+ if (typeof error === 'object' && error !== null && 'statusCode' in error) {+ const statusCode = (error as { statusCode?: unknown }).statusCode;+ if (typeof statusCode === 'number') {+ return statusCode;+ }+ }+ return undefined;+}++function graphErrorCode(error: unknown): string | undefined {+ if (typeof error === 'object' && error !== null && 'code' in error) {+ const code = (error as { code?: unknown }).code;+ if (typeof code === 'string') {+ return code;+ }+ }+ return undefined;+}++function isUnsupportedMePathError(error: unknown): boolean {+ const code = graphErrorCode(error) ?? '';+ const unsupportedCodes = [+ 'BadRequest',+ 'RequestBroker--ParseUri',+ 'ResourceNotFound',+ 'ErrorInvalidUser',+ 'MailboxNotEnabledForRESTAPI',+ ];+ return unsupportedCodes.some((candidate) => code === candidate);+}++function withDeltaRemoval<T extends object>(+ change: T & { '@removed'?: { reason?: string } },+): Omit<T, '@removed'> & { removed: boolean; removedReason: string | null } {+ const { '@removed': removal, ...rest } = change;+ return {+ ...rest,+ removed: removal !== undefined,+ removedReason: removal?.reason ?? null,+ };+}++function graphErrorDetail(error: unknown): string {+ if (typeof error === 'object' && error !== null) {+ const parts: string[] = [];+ const candidate = error as { code?: unknown; message?: unknown; body?: unknown };+ if (candidate.code) {+ parts.push(String(candidate.code));+ }+ if (candidate.message) {+ parts.push(String(candidate.message));+ }+ if (candidate.body) {+ const body = candidate.body;+ parts.push(typeof body === 'string' ? body.slice(0, 500) : JSON.stringify(body).slice(0, 500));+ }+ if (parts.length > 0) {+ return parts.join(' | ');+ }+ }+ if (error instanceof Error && error.message) {+ return error.message;+ }+ return 'No further detail was returned by Microsoft Graph.';+}++function graphError({ error, operation }: { error: unknown; operation: string }): Error {+ const status = graphStatusCode(error);+ const detail = graphErrorDetail(error);+ if (status === 401) {+ return new Error(+ `${operation} failed: the Outlook connection is not authenticated (HTTP 401). Reconnect the account. ${detail}`,+ );+ }+ if (status === 403) {+ return new Error(+ `${operation} failed: Microsoft Graph denied the request (HTTP 403). The connection may lack the permission this endpoint requires, or the mailbox may not be accessible in this access mode. ${detail}`,+ );+ }+ if (status === 404) {+ return new Error(+ `${operation} failed: the requested item was not found (HTTP 404). The ID may be wrong, or the item may have been moved or deleted. ${detail}`,+ );+ }+ if (status === 429) {+ return new Error(+ `${operation} failed: Microsoft Graph throttled the request (HTTP 429). Retry after a short delay. ${detail}`,+ );+ }+ return new Error(`${operation} failed. ${detail}`);+}++const GRAPH_API_VERSIONS = ['v1.0', 'beta'];++const DELTA_LINK_SEGMENT_WILDCARD = '*';++function pathSegments(path: string): string[] {+ return path+ .split('?')[0]+ .split('/')+ .filter((segment) => segment.length > 0)+ .map((segment) => {+ try {+ return decodeURIComponent(segment);+ } catch {+ return segment;+ }+ });+}++function segmentsMatchPattern({+ segments,+ pattern,+}: {+ segments: string[];+ pattern: string[];+}): boolean {+ if (segments.length !== pattern.length) {+ return false;+ }+ return pattern.every((expected, index) =>+ expected === DELTA_LINK_SEGMENT_WILDCARD+ ? segments[index].length > 0+ : segments[index] === expected,+ );+}++function resolveDeltaUrl({+ auth,+ deltaLink,+ expectedPath,+ operation,+}: {+ auth: OAuth2PropertyValue;+ deltaLink: string;+ expectedPath: string;+ operation: string;+}): string {+ const candidate = deltaLink.trim();+ const expectedOrigin = new URL(getGraphBaseUrl(getMicrosoftCloudFromAuth(auth))).origin;+ const expectedPattern = pathSegments(expectedPath);+ const expectation = `Expected an absolute URL on ${expectedOrigin} whose path is /{${GRAPH_API_VERSIONS.join(+ '|',+ )}}/${expectedPattern.join('/')}. Only pass a delta link that this action returned.`;++ let parsed: URL;+ try {+ parsed = new URL(candidate);+ } catch {+ throw new InvalidDeltaLinkError(+ `${operation} failed: the supplied delta link is not an absolute URL. ${expectation}`,+ );+ }++ if (parsed.origin !== expectedOrigin) {+ throw new InvalidDeltaLinkError(+ `${operation} failed: the supplied delta link points at ${parsed.origin}, which is not the Microsoft Graph endpoint of this connection. ${expectation}`,+ );+ }++ const segments = pathSegments(parsed.pathname);++ if (segments.length === 0 || !GRAPH_API_VERSIONS.includes(segments[0])) {+ throw new InvalidDeltaLinkError(+ `${operation} failed: the supplied delta link does not target a supported Microsoft Graph API version. ${expectation}`,+ );+ }++ if (!segmentsMatchPattern({ segments: segments.slice(1), pattern: expectedPattern })) {+ throw new InvalidDeltaLinkError(+ `${operation} failed: the supplied delta link addresses /${segments+ .slice(1)+ .join('/')}, which is outside the mailbox and endpoint this action is configured for. ${expectation}`,+ );+ }++ return parsed.toString();+}++export class InvalidDeltaLinkError extends Error {+ constructor(message: string) {+ super(message);+ this.name = 'InvalidDeltaLinkError';+ }+}++export const outlookAtomicCommon = {+ textBodyHeaders,+ messageSelect,+ mailFolderSelect,+ attachmentSelect,+ wellKnownFolderHint,+ messageIdHint,+ getConfiguredMailbox,+ isAppOnlyConnection,+ isGovernmentCloud,+ encodeGraphId,+ graphStatusCode,+ graphErrorCode,+ graphErrorDetail,+ isUnsupportedMePathError,+ withDeltaRemoval,+ resolveDeltaUrl,+ deltaLinkHint,+ graphError,+};diff --git a/packages/pieces/community/microsoft-outlook/src/lib/common/graph-batch.ts b/packages/pieces/community/microsoft-outlook/src/lib/common/graph-batch.tsnew file mode 100644index 00000000000..d1ea027bbd7--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/src/lib/common/graph-batch.ts@@ -0,0 +1,94 @@+import { Client } from '@microsoft/microsoft-graph-client';++const batchChunkSize = 20;+const maxRetryDelayMs = 15000;++function delay(ms: number): Promise<void> {+ return new Promise((resolve) => setTimeout(resolve, ms));+}++function retryDelayMs(response: GraphBatchResponse): number {+ const retryAfter = response.headers?.['Retry-After'] ?? response.headers?.['retry-after'];+ const seconds = retryAfter ? Number(retryAfter) : NaN;+ if (Number.isFinite(seconds) && seconds > 0) {+ return Math.min(seconds * 1000, maxRetryDelayMs);+ }+ return 2000;+}++async function postChunk({+ client,+ requests,+}: {+ client: Client;+ requests: GraphBatchRequest[];+}): Promise<GraphBatchResponse[]> {+ const response = await client.api('/$batch').post({ requests });+ const responses = (response?.['responses'] ?? []) as GraphBatchResponse[];+ return responses;+}++async function runGraphBatch({+ client,+ requests,+}: {+ client: Client;+ requests: GraphBatchRequest[];+}): Promise<GraphBatchResponse[]> {+ const collected: GraphBatchResponse[] = [];++ for (let index = 0; index < requests.length; index += batchChunkSize) {+ const chunk = requests.slice(index, index + batchChunkSize);+ const responses = await postChunk({ client, requests: chunk });++ const throttled = responses.filter((item) => item.status === 429);+ if (throttled.length === 0) {+ collected.push(...responses);+ continue;+ }++ const waitMs = Math.max(...throttled.map((item) => retryDelayMs(item)));+ await delay(waitMs);++ const retryIds = new Set(throttled.map((item) => item.id));+ const retryRequests = chunk.filter((item) => retryIds.has(item.id));+ const retried = await postChunk({ client, requests: retryRequests });+ const retriedById = new Map(retried.map((item) => [item.id, item]));++ collected.push(...responses.map((item) => retriedById.get(item.id) ?? item));+ }++ return collected;+}++function describeBatchFailure(response: GraphBatchResponse): string {+ const body = response.body;+ if (body && typeof body === 'object' && 'error' in body) {+ const graphError = (body as { error?: { code?: string; message?: string } }).error;+ const parts = [graphError?.code, graphError?.message].filter(Boolean);+ if (parts.length > 0) {+ return parts.join(': ');+ }+ }+ if (typeof body === 'string' && body.length > 0) {+ return body.slice(0, 500);+ }+ return `Microsoft Graph returned HTTP ${response.status} for this item.`;+}++export type GraphBatchRequest = {+ id: string;+ method: string;+ url: string;+ body?: unknown;+ headers?: Record<string, string>;+};++export type GraphBatchResponse = {+ id: string;+ status: number;+ body?: unknown;+ headers?: Record<string, string>;+};++export { runGraphBatch, describeBatchFailure };diff --git a/packages/pieces/community/microsoft-outlook/src/lib/output-schemas.ts b/packages/pieces/community/microsoft-outlook/src/lib/output-schemas.tsindex 75c991c6537..2af6f703b1a 100644--- a/packages/pieces/community/microsoft-outlook/src/lib/output-schemas.ts+++ b/packages/pieces/community/microsoft-outlook/src/lib/output-schemas.ts@@ -55,6 +55,74 @@ const dispatchResultFields: OutputSchema['fields'] = [{ key: 'messageId', label: 'Message ID' },];+const plainEmailAddressFields: OutputSchema['fields'] = [+ { key: 'name', label: 'Name' },+ { key: 'address', label: 'Email Address', format: 'email' },+];++const graphMessageFields: OutputSchema['fields'] = [+ ...messageFields,+ { key: 'inferenceClassification', label: 'Inference Classification' },+ { key: 'isReadReceiptRequested', label: 'Is Read Receipt Requested', format: 'boolean' },+ { key: 'isDeliveryReceiptRequested', label: 'Is Delivery Receipt Requested', format: 'boolean' },+];++const messageSummaryFields: OutputSchema['fields'] = messageFields.filter(+ (field) => field.key !== 'body',+);++const graphDraftMessageFields: OutputSchema['fields'] = graphMessageFields.filter(+ (field) => field.key !== 'from' && field.key !== 'sender',+);++const mailFolderFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Folder ID' },+ { key: 'displayName', label: 'Display Name' },+ { key: 'parentFolderId', label: 'Parent Folder ID' },+ { key: 'childFolderCount', label: 'Child Folder Count', format: 'number' },+ { key: 'unreadItemCount', label: 'Unread Item Count', format: 'number' },+ { key: 'totalItemCount', label: 'Total Item Count', format: 'number' },+ { key: 'isHidden', label: 'Is Hidden', format: 'boolean' },+];++const fullMailFolderFields: OutputSchema['fields'] = [+ ...mailFolderFields,+ { key: 'sizeInBytes', label: 'Size', format: 'filesize' },+ { key: 'wellKnownName', label: 'Well-Known Name' },+];++const graphAttachmentFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Attachment ID' },+ { key: 'name', label: 'File Name' },+ { key: 'contentType', label: 'Content Type' },+ { key: 'size', label: 'Size', format: 'filesize' },+ { key: 'isInline', label: 'Is Inline', format: 'boolean' },+ { key: 'lastModifiedDateTime', label: 'Last Modified At', format: 'datetime' },+];++const batchFailureFields: OutputSchema['fields'] = [+ { key: 'messageId', label: 'Message ID' },+ { key: 'status', label: 'HTTP Status', format: 'number' },+ { key: 'error', label: 'Error' },+];++const focusedInboxOverrideFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Override ID' },+ { key: 'classifyAs', label: 'Classify As' },+ { key: 'senderEmailAddress', label: 'Sender', children: plainEmailAddressFields },+];++const deltaRemovalFields: OutputSchema['fields'] = [+ { key: 'removed', label: 'Removed', format: 'boolean' },+ { key: 'removedReason', label: 'Removal Reason' },+];++const paginationFields: OutputSchema['fields'] = [+ { key: 'count', label: 'Count', format: 'number' },+ { key: 'hasMore', label: 'Has More', format: 'boolean' },+ { key: 'nextLink', label: 'Next Page URL', format: 'url' },+];+export const messageActionOutputSchema: OutputSchema = { fields: messageFields };export const draftMessageActionOutputSchema: OutputSchema = {@@ -105,3 +173,326 @@ export const newAttachmentTriggerOutputSchema: OutputSchema = {{ key: 'parentFolderId', label: 'Parent Folder ID' },],};++export const outlookMessageActionOutputSchema: OutputSchema = { fields: graphMessageFields };++export const outlookDraftMessageActionOutputSchema: OutputSchema = {+ fields: graphDraftMessageFields,+};++export const outlookListMessagesActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'messages', label: 'Messages', labelKey: 'subject', listItems: messageSummaryFields },+ ...paginationFields,+ ],+};++export const outlookSearchMessagesActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'found', label: 'Found', format: 'boolean' },+ { key: 'messages', label: 'Messages', labelKey: 'subject', listItems: graphMessageFields },+ ...paginationFields,+ ],+};++export const outlookListMessagesDeltaActionOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'changes',+ label: 'Changed Messages',+ labelKey: 'subject',+ listItems: [...messageSummaryFields, ...deltaRemovalFields],+ },+ ...paginationFields,+ { key: 'deltaLink', label: 'Delta Link', format: 'url' },+ ],+};++export const outlookGetMessageMimeActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'messageId', label: 'Message ID' },+ { key: 'file', label: 'File', format: 'url' },+ { key: 'fileName', label: 'File Name' },+ { key: 'contentType', label: 'Content Type' },+ { key: 'size', label: 'Size', format: 'filesize' },+ ],+};++export const outlookMoveMessageActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'newMessageId', label: 'New Message ID' },+ { key: 'previousMessageId', label: 'Previous Message ID' },+ { key: 'destinationFolderId', label: 'Destination Folder ID' },+ { key: 'message', label: 'Message', children: graphMessageFields },+ ],+};++export const outlookCopyMessageActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'newMessageId', label: 'New Message ID' },+ { key: 'sourceMessageId', label: 'Source Message ID' },+ { key: 'destinationFolderId', label: 'Destination Folder ID' },+ { key: 'message', label: 'Message', children: graphMessageFields },+ ],+};++export const outlookBatchMoveMessagesActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'destinationFolderId', label: 'Destination Folder ID' },+ { key: 'requestedCount', label: 'Requested Count', format: 'number' },+ { key: 'succeededCount', label: 'Succeeded Count', format: 'number' },+ { key: 'failedCount', label: 'Failed Count', format: 'number' },+ {+ key: 'succeeded',+ label: 'Succeeded',+ labelKey: 'newMessageId',+ listItems: [+ { key: 'messageId', label: 'Previous Message ID' },+ { key: 'newMessageId', label: 'New Message ID' },+ ],+ },+ { key: 'failed', label: 'Failed', labelKey: 'messageId', listItems: batchFailureFields },+ ],+};++export const outlookBatchUpdateMessagesActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'requestedCount', label: 'Requested Count', format: 'number' },+ { key: 'succeededCount', label: 'Succeeded Count', format: 'number' },+ { key: 'failedCount', label: 'Failed Count', format: 'number' },+ {+ key: 'succeeded',+ label: 'Succeeded',+ labelKey: 'messageId',+ listItems: [{ key: 'messageId', label: 'Message ID' }],+ },+ { key: 'failed', label: 'Failed', labelKey: 'messageId', listItems: batchFailureFields },+ ],+};++export const outlookDeleteMessageActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'message', label: 'Result Message' },+ { key: 'messageId', label: 'Message ID' },+ ],+};++export const outlookListMessageAttachmentsActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'messageId', label: 'Message ID' },+ {+ key: 'attachments',+ label: 'Attachments',+ labelKey: 'name',+ listItems: [+ ...graphAttachmentFields,+ { key: 'attachmentType', label: 'Attachment Type' },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const outlookGetMessageAttachmentActionOutputSchema: OutputSchema = {+ fields: [+ ...graphAttachmentFields,+ { key: 'attachmentType', label: 'Attachment Type' },+ { key: 'messageId', label: 'Message ID' },+ ],+};++export const outlookDownloadMessageAttachmentActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'file', label: 'File', format: 'url' },+ { key: 'fileName', label: 'File Name' },+ { key: 'contentType', label: 'Content Type' },+ { key: 'size', label: 'Size', format: 'filesize' },+ { key: 'attachmentId', label: 'Attachment ID' },+ { key: 'messageId', label: 'Message ID' },+ ],+};++export const outlookAddMessageAttachmentActionOutputSchema: OutputSchema = {+ fields: [+ ...graphAttachmentFields,+ { key: 'attachmentType', label: 'Attachment Type' },+ { key: 'messageId', label: 'Message ID' },+ ],+};++export const outlookDeleteMessageAttachmentActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'message', label: 'Result Message' },+ { key: 'messageId', label: 'Message ID' },+ { key: 'attachmentId', label: 'Attachment ID' },+ ],+};++export const outlookMailFolderActionOutputSchema: OutputSchema = { fields: mailFolderFields };++export const outlookFullMailFolderActionOutputSchema: OutputSchema = {+ fields: fullMailFolderFields,+};++export const outlookListMailFoldersActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'folders', label: 'Folders', labelKey: 'displayName', listItems: mailFolderFields },+ ...paginationFields,+ ],+};++export const outlookListChildMailFoldersActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'parentFolderId', label: 'Parent Folder ID' },+ { key: 'folders', label: 'Folders', labelKey: 'displayName', listItems: mailFolderFields },+ ...paginationFields,+ ],+};++export const outlookListMailFoldersDeltaActionOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'changes',+ label: 'Changed Folders',+ labelKey: 'displayName',+ listItems: [...fullMailFolderFields, ...deltaRemovalFields],+ },+ ...paginationFields,+ { key: 'deltaLink', label: 'Delta Link', format: 'url' },+ ],+};++export const outlookCreateMailFolderActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'created', label: 'Created', format: 'boolean' },+ { key: 'folderId', label: 'Folder ID' },+ { key: 'folder', label: 'Folder', children: fullMailFolderFields },+ ],+};++export const outlookCopyMailFolderActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'newFolderId', label: 'New Folder ID' },+ { key: 'sourceFolderId', label: 'Source Folder ID' },+ { key: 'destinationFolderId', label: 'Destination Folder ID' },+ { key: 'folder', label: 'Folder', children: fullMailFolderFields },+ ],+};++export const outlookMoveMailFolderActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'folderId', label: 'Folder ID' },+ { key: 'newFolderId', label: 'New Folder ID' },+ { key: 'destinationFolderId', label: 'Destination Folder ID' },+ { key: 'folder', label: 'Folder', children: fullMailFolderFields },+ ],+};++export const outlookDeleteMailFolderActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'message', label: 'Result Message' },+ { key: 'folderId', label: 'Folder ID' },+ ],+};++export const outlookFocusedInboxOverrideActionOutputSchema: OutputSchema = {+ fields: focusedInboxOverrideFields,+};++export const outlookListFocusedInboxOverridesActionOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'overrides',+ label: 'Overrides',+ labelKey: 'classifyAs',+ listItems: focusedInboxOverrideFields,+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const outlookDeleteFocusedInboxOverrideActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'message', label: 'Result Message' },+ { key: 'overrideId', label: 'Override ID' },+ ],+};++export const outlookGetMailTipsActionOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'mailTips',+ label: 'Mail Tips',+ listItems: [+ { key: 'emailAddress', label: 'Email Address', children: plainEmailAddressFields },+ { key: 'mailboxFull', label: 'Mailbox Full', format: 'boolean' },+ { key: 'deliveryRestricted', label: 'Delivery Restricted', format: 'boolean' },+ { key: 'isModerated', label: 'Is Moderated', format: 'boolean' },+ { key: 'recipientScope', label: 'Recipient Scope' },+ { key: 'maxMessageSize', label: 'Max Message Size', format: 'filesize' },+ { key: 'externalMemberCount', label: 'External Member Count', format: 'number' },+ { key: 'totalMemberCount', label: 'Total Member Count', format: 'number' },+ { key: 'automaticReplies', label: 'Automatic Replies' },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const outlookGetMyProfileActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'User ID' },+ { key: 'displayName', label: 'Display Name' },+ { key: 'mail', label: 'Email Address', format: 'email' },+ { key: 'userPrincipalName', label: 'User Principal Name' },+ { key: 'source', label: 'Source' },+ ],+};++export const outlookGetSupportedTimeZonesActionOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'timeZones',+ label: 'Time Zones',+ labelKey: 'displayName',+ listItems: [+ { key: 'alias', label: 'Alias' },+ { key: 'displayName', label: 'Display Name' },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const outlookSendEmailActionOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'message', label: 'Result Message' },+ { key: 'subject', label: 'Subject' },+ { key: 'recipients', label: 'Recipients' },+ ],+};++export const outlookSendDraftActionOutputSchema: OutputSchema = { fields: dispatchResultFields };++export const outlookReplyToMessageActionOutputSchema: OutputSchema = {+ fields: dispatchResultFields,+};++export const outlookReplyAllToMessageActionOutputSchema: OutputSchema = {+ fields: dispatchResultFields,+};++export const outlookForwardMessageActionOutputSchema: OutputSchema = {+ fields: [...dispatchResultFields, { key: 'recipients', label: 'Recipients' }],+};diff --git a/packages/pieces/community/microsoft-outlook/vitest.config.ts b/packages/pieces/community/microsoft-outlook/vitest.config.tsnew file mode 100644index 00000000000..d87fc4a6954--- /dev/null+++ b/packages/pieces/community/microsoft-outlook/vitest.config.ts@@ -0,0 +1,8 @@+import { defineConfig } from 'vitest/config'++export default defineConfig({+ test: {+ globals: true,+ environment: 'node',+ },+})