我正在尝试使用SendGrid向我的电子邮件发送附件,在这种情况下附件是NSData类型。有没有办法使用SendGrid发送附件而没有在Parse中保存的URL或图像?我想从电话直接转到带附件的电子邮件。
目前电子邮件发送成功,只是没有图像/附件。提前谢谢!
Parse.Cloud.define("sendBookRequestEmail", function(request, response) {
var Buffer = require('buffer').Buffer;
var buffer1 = new Buffer(request.params.image);
var b3 = buffer1.toString('base64');
var SendGrid = require("sendgrid");
SendGrid.initialize("username", "password");
SendGrid.sendEmail({
to: "email",
from: request.params.email,
subject: "Requesting book",
text: "Title: " + request.params.title + "\r\n" + "Author: " + request.params.author + "\r\n" + "ISBN: " + request.params.isbn + "\r\n" + "I want to: " + request.params.bookrequest + "\r\n" + "Notes: " + request.params.notes,
attachments: [request.params.image]
}, {
success: function(httpResponse) {
response.success("success");
console.log(httpResponse);
},
error: function(httpResponse) {
console.error(httpResponse);
}
});
});
答案 0 :(得分:0)
您传递给sendMail调用的对象没有正确的结构。尝试这样的事情:
@ResponseBody
public String check(@RequestParam Integer id, HttpServletRequest request, HttpServletResponse response, Model model) {
boolean a = getSomeResult();
if (a == true) {
return "already saved";
}
return "error exist";
}