我正在使用function buildEmail(attachments){
console.log("attachments", attachments);
var options = {
"from": "xxxxxxxxxxxx@gmail.com",
"sender": "xxxxxxxxxxxx@gmail.com",
"to": "xxxxxxxxxxxx@gmail.com",
"subject": "Report Abuse Mail",
"attachments": []
}
var count = 1;
attachments.images.forEach(function (attachment){
options.attachments.push({
"filename": "screenshot_" + count,
"content": attachment
})
count++
})
options.attachments.push({
"filename": "data.zip",
"content": attachments.data
})
var mail = mailcomposer(options);
return new Promise(function (resolve, reject){
mail.build(function(err, message){
if(err) reject(err);
resolve(message)
})
})
}
function sendEmail(rawData){
console.log("rawData", rawData);
var params = {
RawMessage: {
Data: rawData
},
Destinations: ['xxxxxxxxxxxx@gmail.com'],
Source: 'xxxxxxxxxxxx@gmail.com'
};
return new Promise(function (resolve, reject){
ses.sendRawEmail(params, function(err, data) {
if (err) reject(err);
resolve(data);
});
})
}
buildEmail(attachments)
.then(sendEmail)
.then(console.log)
创建包含附件并通过AWS SES发送的电子邮件。发送邮件后我得到了成功的回复。但是,邮件永远不会送达。不确定我做错了什么
这是我的代码:
{
data: <Buffer 50 4b 03 04 0a 00 00 00 08 00 9d 5a 86 ... >,
images: [ <Buffer 89 50 4e 47 0d 0a 1a 0a,
<Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d
]
}
附件数组中的数据如下:
{
ResponseMetadata: {
RequestId: 'df4aeb16-xxxxxxxxxxxxxxxxxx-21b92055a5cc'
},
MessageId: '01000153d5865455-xxxxxxxxxxxxxxxxxx-000000'
}
我得到的回答是这样的:
var myCanvas; // global variable
function dimage() {
//get canvas image
var element = $("#pnldevice");
html2canvas(element, {
onrendered: function (canvas) {
$("#previewImage").append(canvas);
myCanvas= canvas;
console.log("myCanvas", myCanvas);// F12 to see console and see your logs
//alert(myCanvas);// We prefer to use console :-P
// Maybe you should pass canvas as parameter
onCanvasReady();
}
});
}
function onCanvasReady() {
var imgageData = myCanvas.toDataURL("image/png");
// Now browser starts downloading it instead of just showing it
var newData = imgageData.replace(/^data:image\/png/, "data:application/octet-stream");
$("#btn-Convert-Html2Image").attr("download", "your_pic_name.png").attr("href", newData);
}