我想在我的谷歌應用程序腳本中使用mandrill電子郵件發送api。在谷歌腳本中,我必須使用JSON代碼,但我沒有得到我將如何使用它。我在Google apps腳本中很新。在Google Apps腳本中使用Mandrill API
var m = new mandrill.Mandrill('XXXXXXXXXXX');
var from_email = "[email protected]";
var to = '[
{
"email": "[email protected]",
"name": "Recipient Name"
}
],';
// create a variable for the API call parameters
var params = {
"message": {
"from_email":from_email,
"to":[{"email":to}],
"subject": "Sending a text email from the Mandrill API",
"text": "I'm learning the Mandrill API at Codecademy, it's very difficult."
}
};
function sendTheMail() {
// Send the email!
alert('this is a mail script');
m.messages.send(params, function(res) {
log(res);
}, function(err) {
log(err);
});
}
我不明白如何在Google Apps腳本中使用此代碼。
提取我得到這個錯誤'要求失敗,返回https://mandrillapp.com/api/1.0/messages/send.json代碼500.' – Aakanksha
請參閱我的代碼更改。你需要將json串聯起來。嘗試使用Chrome擴展「郵遞員」嘗試發佈到API。 – AshClarke
Hey thnx a tone ...現在它的工作... – Aakanksha