gpt4 book ai didi

sapui5 - Amazon ses.sendEmail - 如何附加 pdf 文件?

转载 作者:行者123 更新时间:2023-12-04 16:08:53 24 4
gpt4 key购买 nike

我正在尝试使用 Amazon ses.sendEmail 在电子邮件中附加 pdf。但我不知道这样做的参数键。没有附件,它工作得很好。这是我尝试过的。

` var ses = new AWS.SES()

            var params = {
Destination: {
ToAddresses: [
'xxx',
]

},
Message: {
Body: {
Html: {
Data: msg,
Charset: 'UTF-8'
}

},
Subject: { /* required */
Data: 'Test Mail',
Charset: 'UTF-8'
}
},
Attachment:{

},
Source: 'yyy'
};
ses.sendEmail(params, function(err, data) {
if (err) {// an error occurred}
oDialog.close();
MessageToast.show("Email not sent. Some problem occurred!");
}
else {
oDialog.close();
MessageToast.show("Email sent successfully!");
}
});`

最佳答案

对于想要向 SES 电子邮件添加附件的任何其他人,这是我在 NodeJS 中为 lambda 所做的:使用 Nodemailer 和 SES 传输。

npm install --save nodemailer
并在代码中:
// create Nodemailer SES transporter
const transporter = nodemailer.createTransport({
SES: new AWS.SES({
apiVersion: '2010-12-01',
region: "eu-west-1", // SES is not available in eu-central-1
})
});

const emailTransportAttachments = [];
if (attachments && attachments.length !== 0) {
emailTransportAttachments = attachments.map(attachment => ({
filename: attachment.fileName,
content: attachment.data,
contentType: attachment.contentType,
}));
}
const emailParams = {
from,
to,
bcc,
subject,
html,
attachments: emailTransportAttachments,
};

return new Promise((resolve, reject) => {
transporter.sendMail(emailParams, (error, info) => {
if (error) {
console.error(error);
return reject(error);
}
console.log('transporter.sendMail result', info);
resolve(info);
});
});

关于sapui5 - Amazon ses.sendEmail - 如何附加 pdf 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39642788/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com