我想在我的谷歌应用程序脚本中使用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