2
私はMeteorを使用しており、pdfを電子メールに添付しようとしています。私は現在、pdfを新しいウィンドウで開き、pdfを表示するbase64文字列としてクライアントに返します。私はpdfの形式で電子メールの添付ファイルとしてbase64を添付したいと思います。メーリングリストのためのMeteorにbase64 PDFを電子メールの添付ファイルとして添付
サーバー方法:クライアントにbase64文字列を返します
Meteor.methods({
sendEmail: function (to, from, subject, html,attachment) {
check([to, from, subject, html,attachment], [String]);
// Let other method calls from the same client start running,
// without waiting for the email sending to complete.
this.unblock();
Email.send({
to: to,
from: from,
subject: subject,
html: html,
attachment:attachment
});
}
});
抜粋:現在のPDFを表示
webshot(html_string, fileName, options, function(err) {
fs.readFile(fileName, function (err, data) {
if (err) {
return console.log(err);
}
fs.unlinkSync(fileName);
fut.return(data);
});
});
console.log("------------Waiting till PDF generated-----------");
pdfData = fut.wait();
base64String = new Buffer(pdfData).toString('base64');
console.log("------------Return result-----------");
return base64String;
クライアント側コード:
Meteor.call('screenshot',html,style,function(err, res) {
if (err) {
console.error(err);
} else if (res) {
window.open("data:application/pdf;base64, " + res);//view PDF result
if(localbool===true) {
Meteor.call('sendEmail',
'[email protected]',//to
'[email protected]',//from
'Hello from Meteor!',//subject
'Sample HTML'//html
**What do I put here to attach base64 PDF**
);//close call for email send
alert("email sent!");
}
}
});
pdf添付ファイルとしてbase64文字列を添付するにはどうすればよいですか? Meteorメールで送信するデータを得ることはできないようですが、「予想される文字列とオブジェクトが見つかりました」というエラーが表示されます。
ありがとう、