I use Sendgrid Nodejs to send email to my customer, like this:
export function Orders_afterInsert(item, context) {
sgMail.setApiKey('SG.MKw1...');
const msg = {
to: [{"email":item.customerEmail}],
from: 'emotiony.store@gmail.com',
cc: [{"email":"emotiony.store@gmail.com"},{"email":"emotionyproduction@gmail.com"}],
subject: 'Emotiony xác nhận đặt hàng dịch vụ âm nhạc từ ${item.customerName}',
templateId: 'd-d3d7f6...',
dynamic_template_data: {
cus_name: item.customerName,
cus_service: item.serviceName,
cus_phone: item.phoneNumber,
cus_email: item.customerEmail,
cus_class: item.customerClass,
cus_deadline: item.customerDeadline.toLocaleString("en-US", options),
cus_purpose: item.orderPurpose,
cus_detail: [{
"type": 'text/html',
"value": item.orderDetail,
}],
},
};
sgMail.send(msg); //TODO: write your code here...
}
Customer will input Order Detail with a html richtext .
Now i want send this html variables to Sendgrid template. With above code, Sendgrid template just load it as a text, not html with a format. Please help me right code. Thanks you all.