Can't open the attachment in the email

I send the attachment in the base64 format, set a content type and a size properly, I also see the attachment in the email with the correct name and size, but when try to open it got “Couldn’t preview file. There was a problem displaying this image”. Also try to download and open, but got the error “Can’t open the file”. The size and format are correct. Tried with png and pdf with gmail emails. But I need pdf for this specific case.
here is how i convert the file to base64:
const response = await fetch(purchaseRequest.fileItem.attachedFile.url);
if (!response.ok) {
throw new Error(
Failed to fetch file from ${purchaseRequest.fileItem.attachedFile.url},
);
}
const fileBuffer = await response.buffer();
const base64Content = fileBuffer.toString(‘base64’);

await nylasService.sendEmail(connection.id, {
to: [
{
email: purchaseRequest.orderId.company.email,
},
],
from: [
{
email: ctx.state.user.email,
},
],
subject,
body,
attachments: [
{
content: base64Content,
content_type: purchaseRequest.fileItem.attachedFile,
filename: ${purchaseRequest.fileItem.attachedFile.hash}.pdf,
id: purchaseRequest.fileItem.attachedFile.id,
is_inline: false,
size: purchaseRequest.fileItem.attachedFile.size,
},
],
});

The email body and subject are correct. Thanks you in advance!

Hi @BnDigital thanks for reaching out, let me take a look and circle back :slightly_smiling_face:

Check out this article related to sending attachments of different sizes.

@BnDigital By using our SDKs you need to worry about the size or the format :wink:

1 Like

Hello colleagues, as you can see in the listed information above the size limits is good and not too big
Also I have tried a lot of different approaches, changing name fields and other details.

Nothing helps.
Can you please send an example of working email with attachments or git repo that you have with included example.

There is no information in any of your repos with examples due to attachments.

Please if this feature broken or you still work with it , just confirm.
It would be great if you can help with this issue, thank you

@Blag , @ram

Can you help please with this issue?