mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Merge 4baa51c4a4
into d2dd1796a8
This commit is contained in:
commit
87af47e83a
|
@ -209,9 +209,54 @@ export const mailFields: INodeProperties[] = [
|
|||
{
|
||||
displayName: 'Attachments',
|
||||
name: 'attachments',
|
||||
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: 'Comma-separated list of binary properties',
|
||||
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',
|
||||
|
|
|
@ -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": [
|
||||
|
|
|
@ -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}`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue