Вы можете попробовать следующий фрагмент из Sendgrid API:
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: 'recipient@example.org',
from: 'sender@example.org',
subject: 'Hello attachment',
html: '<p>Here’s an attachment for you!</p>',
attachments: [
{
content: 'Some base 64 encoded attachment content',
filename: 'some-attachment.txt',
type: 'plain/text',
disposition: 'attachment',
contentId: 'mytext'
},
],
};
Итак, в вашем контексте:
module.exports = function (context, myQueueItem) {
var message = {
"personalizations": [ { "to": [ { "email": "testto@test.com" } ] } ],
from: { email: "testfrom@test.com" },
subject: "Azure news",
content: [{
type: 'text/plain',
value: myQueueItem
}],
attachments: [
{
content: 'Some base 64 encoded attachment content',
filename: 'some-attachment.txt',
type: 'plain/text',
disposition: 'attachment',
contentId: 'mytext'
},
]
};
context.done(null, {message});
};