- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我想使用 nodemailer 和 node.js 附加一个 PDF 文档,但是,我找到的关于 nodemailer 附件的唯一示例是 .txt 文件 ( here )。
有谁知道 nodemailer 是否支持 PDF 文档附件?
最初似乎可以附加 PDF,但通过电子邮件到达的 PDF 文件似乎已损坏(见图)。
代码:(改编自 Mahesh 的回答)
fs.readFile('/filePath/fileName.pdf', function (err, data) {
if (err) throw err;
var mailOptions = {
from: 'Test <formEmail@gmail.com>', // sender address
to: 'toPersonName <toEmail@gmail.com>', // list of receivers
subject: 'Attachment', // Subject line
text: 'Hello world attachment test', // plaintext body
html: '<b>Hello world attachment test HTML</b>', // html body
attachments: [
{
filename: 'fileName.pdf',
contentType: 'application/pdf'
}]
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
console.log(data);
});
终端响应:
<Buffer 25 50 44 46 2d 31 2e 33 0a 25 c4 e5 f2 e5 eb a7 f3 a0 d0 c4 c6 0a 34 20 30 20 6f 62 6a 0a 3c 3c 20 2f 4c 65 6e 67 74 68 20 35 20 30 20 52 20 2f 46 69 ... >
Message sent: 250 2.0.0 OK 1443026036 hq8sm3016566pad.35 - gsmtp
最佳答案
是的,你可以。您必须添加要附加的文件的路径。
transporter.sendMail({
from: 'foo@bar.com',
to: 'bar@foo.com',
subject: 'An Attached File',
text: 'Check out this attached pdf file',
attachments: [{
filename: 'file.pdf',
path: 'C:/Users/Username/Desktop/somefile.pdf',
contentType: 'application/pdf'
}],
function(err, info) {
if (err) {
console.error(err);
} else {
console.log(info);
}
}
});
关于javascript - Node.js 和 Nodemailer : Can we attached PDF documents to emails?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32730631/
我正在尝试发送一封带有附件和 html 内容的邮件。我知道如何分别发送 html 内容和附件,但是是否可以同时发送 html 和附件? 这是我尝试过的: public static void send
所以我真的很难弄清楚什么时候应该附加到一个对象,什么时候不应该附加到一个对象。首先,这是我的(非常简化的)对象模型的小图。 在我的 DAL 中,我每次执行与数据相关的操作时都会创建一个新的 DataC
更新:Docker 0.9.0 现在使用 libcontainer,从 LXC 转移参见:Attaching process to Docker libcontainer container 我正在运
我按照此页面上的说明进行操作: https://developers.facebook.com/docs/plugins/share-button/#settings 我得到一个工作共享对话框,但是当
我有一个现有代码可以正确下载和处理一些电子邮件。 要处理的电子邮件必须有一个或多个 xml 作为附件,现在我正在迁移这个过程从当前的标准邮件帐户到一个认证系统,该系统将邮件包装到一个新的电子邮件。 因
我不太明白通过 attach api 连接到另一个虚拟机是什么意思.我读到每个 Java 程序都在其自己的虚拟机中运行(参见 here )。那么对于一个程序“附加”到另一个 jvm 进程以便它可以访问
无论如何我可以强制使用这种方法,ActiveStorage::Attached#attach不排队后台工作?换句话说,我想禁用似乎包含在 ActiveStorage::Attached#attach
在 Eclipse 插件开发中,我通过 MANIFEST.MF 文件导入包。所以我没有 lib 文件夹,也没有引用的库部分。 即使对于像 String.format() 这样最基本的方法,我也看不到
我不知道执行此操作的确切方法。我想要一种方法,而不是针对 Eclipse 中所有项目的单个项目。请告诉我如何解决这个问题。 最佳答案 这是在 Eclipse 中的类路径中的一个 jar,你有 附加了一
我有一个多个文件要附加到选择器 View 中。当用户选择该选择器 View 项目时,他们可以单击电子邮件按钮来附加所选文件。我该如何在选择器 View 中执行此操作? 这是我的示例代码。 M 文件:
经过this之后通过讨论,我相信附加到同一虚拟机的选项默认情况下已在 OpenJDK11 中禁用。 我正在尝试将 java 代理升级到 OpenJDK11,在测试用例中,当调用 VirtualMach
首先 - 我知道 UWSGI 建议使用 smart-attach-daemon 来自:http://uwsgi-docs.readthedocs.io/en/latest/AttachingDaemo
我使用axios从Reaction网站调用我的API(Django服务器),我希望在授权头的每个请求中都出现一个带有持有者令牌的授权头。。这就是我如何设置授权头apiClient.defaults.h
我在 heroku 上有一个 rails 应用程序,我无法运行我最新的数据库更改。运行 heroku run rake db:migrate给我 Running `rake db:migrate` a
我使用 strope.js 构建一个简单的 IM(web)。 我有 2 个页面:index.html(用于登录)和 myChat.html(主聊天 View )。 当我通过index.html中的ji
我尝试过“heroku run python manage.py migrate”并收到“超时等待dyno,请参阅https://devcenter.heroku.com/articles/one-o
我正在使用 OpenGL 帧缓冲区对象 (FBO) 在 iOS 上实现模板阴影。代码有效——也就是说,从视觉上看,模板缓冲区正在完成这项工作,而且性能似乎还不错。 但是,当我通过 OpenGL ES
我正在尝试使用 slack 附件来记录应用程序错误,但是像堆栈跟踪这样的大字段表现得很奇怪。 首先,当使用附件时,表格似乎固定为任意宽度,是否有任何更改,以便可以允许更宽的值?否则 50+% 的松弛窗
我花了好几天时间寻找一种解决方案,将带有附件的属性字符串放到 NSPasteboard 上。 我可以读取带有附件的 RTFD 文件,修改其文本和属性,然后将其粘贴到 NSPasteboard 上以供其
我想对数据框的列进行许多修改。但是,由于需要大量的列和转换,我想避免一遍又一遍地使用数据框名称。 在 SAS 数据步中,在一个数据步中,您可以创建一个变量并在定义后立即引用它: data A; s
我是一名优秀的程序员,十分优秀!