Files
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

63 lines
1.7 KiB
TypeScript

import type {
IDataObject,
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
} from 'n8n-workflow';
import {
createEmailBodyWithN8nAttribution,
createEmailBodyWithoutN8nAttribution,
} from '../../../../../../utils/sendAndWait/email-templates';
import {
getSendAndWaitConfig,
getSendAndWaitProperties,
createButton,
} from '../../../../../../utils/sendAndWait/utils';
import { createMessage } from '../../helpers/utils';
import { microsoftApiRequest } from '../../transport';
export const description: INodeProperties[] = getSendAndWaitProperties([
{
displayName: 'To',
name: 'toRecipients',
description: 'Comma-separated list of email addresses of recipients',
type: 'string',
required: true,
default: '',
},
]);
export async function execute(this: IExecuteFunctions, index: number, items: INodeExecutionData[]) {
const toRecipients = this.getNodeParameter('toRecipients', index) as string;
const config = getSendAndWaitConfig(this);
const buttons: string[] = [];
for (const option of config.options) {
buttons.push(createButton(option.url, option.label, option.style));
}
let bodyContent: string;
if (config.appendAttribution !== false) {
const instanceId = this.getInstanceId();
bodyContent = createEmailBodyWithN8nAttribution(config.message, buttons.join('\n'), instanceId);
} else {
bodyContent = createEmailBodyWithoutN8nAttribution(config.message, buttons.join('\n'));
}
const fields: IDataObject = {
subject: config.title,
bodyContent,
toRecipients,
bodyContentType: 'html',
};
const message: IDataObject = createMessage(fields);
const body: IDataObject = { message };
await microsoftApiRequest.call(this, 'POST', '/sendMail', body);
return items;
}