diff --git a/packages/nodes-base/nodes/SendGrid/MailDescription.ts b/packages/nodes-base/nodes/SendGrid/MailDescription.ts index 067c52597c..faa4796143 100644 --- a/packages/nodes-base/nodes/SendGrid/MailDescription.ts +++ b/packages/nodes-base/nodes/SendGrid/MailDescription.ts @@ -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', diff --git a/packages/nodes-base/nodes/SendGrid/SendGrid.node.json b/packages/nodes-base/nodes/SendGrid/SendGrid.node.json index 2aea57de95..0399c5523c 100644 --- a/packages/nodes-base/nodes/SendGrid/SendGrid.node.json +++ b/packages/nodes-base/nodes/SendGrid/SendGrid.node.json @@ -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": [ diff --git a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts index c803521206..978d7065f8 100644 --- a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts +++ b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts @@ -532,7 +532,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; }; @@ -582,11 +588,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); @@ -594,6 +600,8 @@ export class SendGrid implements INodeType { content: dataBuffer.toString('base64'), filename: binaryData.fileName || 'unknown', type: binaryData.mimeType, + disposition, + content_id: contentId || `attachment${ai}`, }); }