javascript - 在 Ionic 框架中使用电子邮件发送附件
问题描述
我有这个代码:
this.email.isAvailable().then((available: boolean) =>{
if(available) {
//Now we know we can send
}
});
let email = {
to: 'xxx@xxx.xxx',
attachments: [
'file:///C:/Users/xxx/Downloads/ZZZ_RonData.txt',
'file:///C:/Users/xxx/Downloads/ZZZZ_LogIn_Ron.txt',
'file:///C:/Users/xxx/Downloads/ZZZZ_LogOut_Ron.txt',
'file:///C:/Users/xxx/Downloads/ZZ_signature.png'
],
subject: 'User\'s Info',
body: '',
isHtml: true
};
// Send a text message using default options
this.email.open(email);
上面的文件位于我的下载文件夹中,我的用户是 xxx。我确信没有拼写错误。问题是当我运行此代码时,我收到了电子邮件但没有附件。我做错了什么?
编辑:有人说我需要在位置之前放置文件,但我不确定他的意思。
编辑:类路径或我提供的代码是否存在问题。
编辑:我的路径是文件目录的正确格式吗?
这是 Ionic 给出的示例:
let email = {
to: 'max@mustermann.de',
cc: 'erika@mustermann.de',
bcc: ['john@doe.com', 'jane@doe.com'],
attachments: [
'file://img/logo.png',
'res://icon.png',
'base64:icon.png//iVBORw0KGgoAAAANSUhEUg...',
'file://README.pdf'
],
subject: 'Cordova Icons',
body: 'How are you? Nice greetings from Leipzig',
isHtml: true
};
最终编辑:我正在使用 Visual Studio,当我按住 ctrl 单击文件路径时,文件出现了。这意味着文件目录是正确的!
解决方案
推荐阅读
- textfield - 我在 vuetify 的文本字段中找不到任何 padstart () 实现示例
- python - 缩减行梯队表单脚本在特定情况下不起作用
- angularjs - Angular:req.handle.writev 不是函数,运行 Angular 旧应用程序时出错
- python - Pyinstaller .exe 无法同时创建一个文件和 noconsole
- makefile - LZMA 的 makefile 中出现“***缺少分隔符”错误
- android - Firebase 连接问题 - Android
- r - 在二维数据框中访问/索引
- azure - 如何为成功的 SQL DacPac 导入创建事件网格订阅?
- java - 如何通过 Java 使用 Selenium 在文章标签内定位按钮
- javascript - removeClass 在 console.log 中工作,但不在 DOM 中