mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(Email Trigger (IMAP) Node): Handle attachments correctly (#9410)
This commit is contained in:
committed by
GitHub
parent
bf549301df
commit
68a6c81729
@@ -298,7 +298,11 @@ export class EmailReadImapV2 implements INodeType {
|
||||
|
||||
// Returns the email text
|
||||
|
||||
const getText = async (parts: MessagePart[], message: Message, subtype: string) => {
|
||||
const getText = async (
|
||||
parts: MessagePart[],
|
||||
message: Message,
|
||||
subtype: string,
|
||||
): Promise<string> => {
|
||||
if (!message.attributes.struct) {
|
||||
return '';
|
||||
}
|
||||
@@ -309,12 +313,14 @@ export class EmailReadImapV2 implements INodeType {
|
||||
);
|
||||
});
|
||||
|
||||
if (textParts.length === 0) {
|
||||
const part = textParts[0];
|
||||
if (!part) {
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
return await connection.getPartData(message, textParts[0]);
|
||||
const partData = await connection.getPartData(message, part);
|
||||
return partData.toString();
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
@@ -355,7 +361,7 @@ export class EmailReadImapV2 implements INodeType {
|
||||
?.filename as string,
|
||||
);
|
||||
// Return it in the format n8n expects
|
||||
return await this.helpers.prepareBinaryData(Buffer.from(partData), fileName);
|
||||
return await this.helpers.prepareBinaryData(partData.buffer, fileName);
|
||||
});
|
||||
|
||||
attachmentPromises.push(attachmentPromise);
|
||||
|
||||
Reference in New Issue
Block a user