feat(Send Email Node): Add content-id for email attachments (#3632)

This commit is contained in:
pemontto 2023-05-19 13:31:02 +01:00 committed by GitHub
parent e88b9d880a
commit 8fe8aad6a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,9 @@ import type {
IExecuteFunctions, IExecuteFunctions,
INodeExecutionData, INodeExecutionData,
INodeProperties, INodeProperties,
JsonObject,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
import { createTransport } from 'nodemailer'; import { createTransport } from 'nodemailer';
import type SMTPTransport from 'nodemailer/lib/smtp-transport'; import type SMTPTransport from 'nodemailer/lib/smtp-transport';
@ -100,7 +102,7 @@ const properties: INodeProperties[] = [
type: 'string', type: 'string',
default: '', default: '',
description: description:
'Name of the binary properties that contain data to add to email as attachment. Multiple ones can be comma-separated.', 'Name of the binary properties that contain data to add to email as attachment. Multiple ones can be comma-separated. Reference embedded images or other content within the body of an email message, e.g. <img src="cid:image_1">',
}, },
{ {
displayName: 'CC Email', displayName: 'CC Email',
@ -227,6 +229,7 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
attachments.push({ attachments.push({
filename: binaryData.fileName || 'unknown', filename: binaryData.fileName || 'unknown',
content: await this.helpers.getBinaryDataBuffer(itemIndex, propertyName), content: await this.helpers.getBinaryDataBuffer(itemIndex, propertyName),
cid: propertyName,
}); });
} }
@ -255,7 +258,8 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
}); });
continue; continue;
} }
throw error; delete error.cert;
throw new NodeApiError(this.getNode(), error as JsonObject);
} }
} }