first commit
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
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
This commit is contained in:
+62
@@ -0,0 +1,62 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user