我正在尝试使用aws-ses从我的角度应用程序发送带有附件(blob)的电子邮件。我没有收到附件,但收到了电子邮件。 (blob包含JSON。)
这是我的代码:
sendEmail(blob: any, completedCallback) {
let rawMessage = '';
let buffer = JSON.stringify(blob);
rawMessage += 'To: someone@example.com\n';
rawMessage += 'From: snnoreply@example.com\n';
rawMessage += 'Subject: Hello, World!\n';
rawMessage += '\n';
rawMessage += 'MIME-Version: 1.0\n';
rawMessage += 'Content-Type: multipart/mixed; boundary=\"NextPart\"\n\n';
rawMessage += '--NextPart\n';
rawMessage += 'Content-Type: text/html; charset=us-ascii\n\n';
rawMessage += 'This is the body of the email.\n';
rawMessage += '--NextPart\n';
rawMessage += 'Content-Type: application/json;\n';
rawMessage += 'Content-Disposition: attachment; filename=\"attachment.txt\"\n\n';
rawMessage += buffer + '\n\n';
rawMessage += '--NextPart--';
let eParams = {
RawMessage: {
Data: rawMessage
},
Destinations: ['somone@example.com'],
Source: '<snnoreply@example.com>'
};
this.ses.sendRawEmail(eParams, function(err, resp) {
if (err) {
console.log('failed with error: ' + err);
err['msg1'] = 'Email sending failed';
completedCallback(err);
} else {
console.log('===EMAIL SENT===');
resp['msg1'] = 'Email sent';
completedCallback(resp);
}
});
console.log('EMAIL CODE END');
}
我的代码中是否有错误/不完整。请指出正确的方向。