i want to use Sendinblue api with my lb4 application to send mails but i have some difficulties in attachment , can i get a clean example for linking sendinblue api V3 with loopback4 (nodejs) thanks
Asked
Active
Viewed 1,748 times
1 Answers
1
I followed the steps mentioned in their reference docs and got the below script working!
var request = require("request");
var options = {
method: 'POST',
url: 'https://api.sendinblue.com/v3/smtp/email',
headers: {
accept: 'application/json',
'content-type': 'application/json',
'api-key': 'API-KEY'
},
body: {
sender: {name: 'Your Name', email: 'youremail@gmail.com'},
to: [{email: 'recipient@gmail.com', name: 'Recipient name'}],
attachment: [
{
url: 'http://personal.psu.edu/xqz5228/jpg.jpg', // Should be publicly available and shouldn't be a local file
name: 'myAttachment.jpg'
}
],
htmlContent: 'This is a test Content',
subject: 'This is test Subject'
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Though you haven't stated what issue you are facing exactly with the attachment but I am thinking it might have to do with the attachment url not being absolute url and instead a local file. If that's the issue, then I would suggest you to convert the attachment to base64 and then pass it following their reference document.
Please let me know if it helps! Thanks

rudy0807
- 152
- 1
- 8