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

View File

@@ -3,7 +3,9 @@ import type {
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
JsonObject,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
import { createTransport } from 'nodemailer';
import type SMTPTransport from 'nodemailer/lib/smtp-transport';
@@ -100,7 +102,7 @@ const properties: INodeProperties[] = [
type: 'string',
default: '',
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',
@@ -227,6 +229,7 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
attachments.push({
filename: binaryData.fileName || 'unknown',
content: await this.helpers.getBinaryDataBuffer(itemIndex, propertyName),
cid: propertyName,
});
}
@@ -255,7 +258,8 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
});
continue;
}
throw error;
delete error.cert;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}