Parse platform 使用模板解析Cloud-Sendgrid

Parse platform 使用模板解析Cloud-Sendgrid,parse-platform,sendgrid,parse-cloud-code,Parse Platform,Sendgrid,Parse Cloud Code,有人能够将SendGrid模板与解析云代码一起使用吗 这是可行的,但只发送文本,关于如何使用模板id有什么想法吗 我试过使用过滤器,但没有成功 Parse.Cloud.define("sendEmail", function(request, response) { // Import SendGrid module and call with your SendGrid API Key var sg = require('sendgrid')('your SendGrid API k

有人能够将SendGrid模板与解析云代码一起使用吗

这是可行的,但只发送文本,关于如何使用模板id有什么想法吗

我试过使用过滤器,但没有成功

Parse.Cloud.define("sendEmail", function(request, response) {

  // Import SendGrid module and call with your SendGrid API Key
  var sg = require('sendgrid')('your SendGrid API key here');

  // Create the SendGrid Request
  var reqSG = sg.emptyRequest({
    method: 'POST',
    path: '/v3/mail/send',
    body: {
      personalizations: [
        {
          to: [
            {
              // This field is the "to" in the email
              email: request.params.toEmail,
            },
          ],
          // This field is the "subject" in the email
          subject: request.params.subject,
        },
      ],
      // This field contains the "from" information
      from: {
        email: 'info@youremail.com',
        name: 'Your Name',
      },
      // This contains info about the "reply-to"
      // Note that the "reply-to" may be different than the "from"
      reply_to: {
        email: 'info@youremail.com',
        name: 'Your Name',
      },
      content: [
        {
          type: 'text/plain',
          value: request.params.body,
        },
      ],
    },
  });

  sg.API(reqSG, function(SGerror, SGresponse) {
    // Testing if some error occurred
    if (SGerror) {
      // Ops, something went wrong
      console.error('Error response received');
      console.error('StatusCode=' + SGresponse.statusCode);
      console.error(JSON.stringify(SGresponse.body));
      response.error('Error = ' + JSON.stringify(SGresponse.body));
    } 
    else {
      // Everything went fine
      console.log('Email sent!');
      response.success('Email sent!');
    }
  });

});

这是Back4App上的文档

如果有人在寻找答案,结果很简单

将模板id添加为个性化设置,并将消息类型更改为text/html

 template_id:"your template_id",
              content: [
                {

                  type: 'text/html',
                  // This field is the body of the email
                  value: "",
                },
              ],