2017-10-01 7 views
1

誰もがParse Cloud CodeでSendGridテンプレートを使用できましたか?Parse Cloud - Sendgrid with Template

これは機能しますが、テキストのみ、template_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: '[email protected]', 
     name: 'Your Name', 
     }, 
     // This contains info about the "reply-to" 
     // Note that the "reply-to" may be different than the "from" 
     reply_to: { 
     email: '[email protected]', 
     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!'); 
    } 
    }); 

}); 

これは、誰もが、それは簡単なことが判明した答えを探している場合は、

は、パーソナライゼーションとしてTEMPLATE_IDを追加し、メッセージの種類にテキストを変更Back4App https://docs.back4app.com/docs/integrations/using-sendgrid-to-send-email/

答えて

1

のドキュメントからです/ html、

template_id:"your template_id", 
       content: [ 
       { 

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