This commit is contained in:
Denis Perov 2025-03-05 17:37:09 +01:00 committed by GitHub
commit 87af47e83a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 9 deletions

View file

@ -209,9 +209,54 @@ export const mailFields: INodeProperties[] = [
{
displayName: 'Attachments',
name: 'attachments',
type: 'string',
default: '',
description: 'Comma-separated list of binary properties',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
displayName: 'Attachment',
name: 'data',
values: [
{
displayName: 'Property',
name: 'property',
type: 'string',
default: 'data',
description: 'Binary property name',
},
{
displayName: 'Content Disposition',
name: 'disposition',
type: 'options',
default: 'attachment',
options: [
{
name: 'Attachment',
value: 'attachment',
},
{
name: 'Inline',
value: 'inline',
},
],
description:
"The attachment's content-disposition specifies how you would like the attachment to be displayed",
},
{
displayName: 'Content ID',
name: 'contentId',
type: 'string',
default: '',
description:
'The attachment\'s Content ID is used when the Disposition is set to "inline" and the attachment is an image, allowing the file to be displayed within the body of the email',
hint: 'Default to "attachmentN", where N is the attachment\'s index (zero-based)',
},
],
},
],
description: 'File attachments',
},
{
displayName: 'BCC Email',

View file

@ -1,7 +1,7 @@
{
"node": "n8n-nodes-base.sendGrid",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"nodeVersion": "1.1",
"codexVersion": "1.1",
"categories": ["Marketing", "Communication"],
"resources": {
"credentialDocumentation": [

View file

@ -530,7 +530,13 @@ export class SendGrid implements INodeType {
enableSandbox: boolean;
sendAt: string;
headers: { details: Array<{ key: string; value: string }> };
attachments: string;
attachments: {
data: {
property: string;
disposition: 'attachment' | 'inline';
contentId: string;
}[];
};
categories: string;
ipPoolName: string;
};
@ -580,11 +586,11 @@ export class SendGrid implements INodeType {
];
}
if (attachments) {
if (attachments?.data) {
const attachmentsToSend = [];
const binaryProperties = attachments.split(',').map((p) => p.trim());
for (const property of binaryProperties) {
for (const ai in attachments.data) {
const { property, disposition, contentId } = attachments.data[ai];
const binaryData = this.helpers.assertBinaryData(i, property);
const dataBuffer = await this.helpers.getBinaryDataBuffer(i, property);
@ -592,6 +598,8 @@ export class SendGrid implements INodeType {
content: dataBuffer.toString('base64'),
filename: binaryData.fileName || 'unknown',
type: binaryData.mimeType,
disposition,
content_id: contentId || `attachment${ai}`,
});
}