Skip to content

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

1.5 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import { microsoftOutlookAuth } from '../common/auth';
import { outlookCommon } from '../common/client';
import { mailFolderIdDropdown, messageIdDropdown } from '../common/props';
import { messageActionOutputSchema } from '../output-schemas';

export const moveEmailToFolderAction = createAction({
	auth: microsoftOutlookAuth,
	name: 'moveEmailToFolder',
	classification: 'WRITE',
	displayName: 'Move Email to Folder',
	description: 'Move an email into another folder.',
	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: {
		messageId: messageIdDropdown({
			displayName: 'Email',
			description: 'The email to move.',
			required: true,
		}),
		destinationFolderId: mailFolderIdDropdown({
			displayName: 'Destination Folder',
			description: 'Folder to move the email into.',
			required: true,
		}),
	},
	async run(context) {
		const { messageId, destinationFolderId } = context.propsValue;

		const client = outlookCommon.createClient(context.auth);

		const response = await client.api(`${outlookCommon.mailboxPrefix(context.auth)}/messages/${messageId}/move`).post({
			destinationId: destinationFolderId,
		});

		return response;
	},
});