Nodejs sdk do not support to send email with multipart form data with attachments more than 3MB.
The sdk requires a model of SendMessageRequest, but there isn’t a way to pass multipart form data.
Using the following code to send the
===============SDK code =================
export const sendEmailWithAttachments = async ({
grantId,
from,
fromName,
to,
subject,
text,
replyToMessageId,
files = [],
cc = [],
}: SendEmailParams) => {
console.log(`SendEmail with reply to: ${replyToMessageId}, subject: ${subject}`)
const filesToUpload = Array.isArray(files) ? files : [files]
const attachments: CreateAttachmentRequest[] = []
for (const file of filesToUpload) {
attachments.push({
content: file.data.split("base64,")?.[1] ?? "",
filename: file.filename,
contentType: getContentType(file.filename),
})
}
const message: SendMessageRequest = {
subject,
body: text,
to: [{ email: to }],
cc: cc.map((email) => ({ email })),
from: [{ email: from, name: fromName }],
...(replyToMessageId && { replyToMessageId: replyToMessageId }),
trackingOptions: {
threadReplies: true,
opens: true,
},
attachments: attachments,
}
const resp = await nylas.messages.send({
identifier: grantId,
requestBody: message,
})
return resp.data
}
How can i send attachments of more than 3MB using nodejs sdk?
What i’m doing wrong here?