Hi I am trying to send a pdf attachment with an email.
sgMail.setApiKey(my_key);
fs.readFile('pdf/4.pdf', function(err, data) {
sgMail.send({
to : 'dinesh@mail.com',
from : 'xxxxxxxxx@jdk.com',
subject : 'Report',
attachments : [{filename: 'Report.pdf',
content: data,
type: 'application/pdf',
}],
html : 'bla bla'})})
This code gives me an error
Invalid type. Expected: string, given: object.
But I found this code snippet by another stackoverflow answer. It says you don't need to pass the uri encoded data for the content. (That question in the comments)
How do I achieve this using node js?