Javascript 无法将AttachmentPath从字符串强制转换为可读数组
我正在尝试使用react native smtp mailer发送带有附加图像的电子邮件。attachmentPaths是一个数组,是一个动态更新的状态,但当我尝试发送电子邮件时,我收到错误attachmentPaths无法从字符串转换为可读数组。这是我的密码Javascript 无法将AttachmentPath从字符串强制转换为可读数组,javascript,node.js,reactjs,react-native,react-native-android,Javascript,Node.js,Reactjs,React Native,React Native Android,我正在尝试使用react native smtp mailer发送带有附加图像的电子邮件。attachmentPaths是一个数组,是一个动态更新的状态,但当我尝试发送电子邮件时,我收到错误attachmentPaths无法从字符串转换为可读数组。这是我的密码 RNSmtpMailer.sendMail({ mailhost: 'smtp.gmail.com', port: '465', ssl: true, // optional. if false, t
RNSmtpMailer.sendMail({
mailhost: 'smtp.gmail.com',
port: '465',
ssl: true, // optional. if false, then TLS is enabled. Its true by default in android. In iOS TLS/SSL is determined automatically, and this field doesn't affect anything
username: 'email@gmail.com',
password: 'password',
fromName: 'Ssadd', // optional
replyTo: 'email@gmail.com', // optional
recipients: 'email1@gmail.com,email2@gmail.com',
subject: 'subject',
htmlBody: '<h1>header</h1><p>body</p>',
attachmentPaths: JSON.stringify(this.state.paths), //
attachmentNames: JSON.stringify(this.state.filenames), // required in android, these are renames of original files. in ios filenames will be same as specified in path. In a ios-only application, no need to define it
}).then((success) => console.log(success));
};
RNSmtpMailer.sendMail({
邮件主机:“smtp.gmail.com”,
端口:'465',
ssl:true,//可选。如果为false,则启用TLS。在android中默认为true。在iOS中,TLS/ssl自动确定,并且此字段不影响任何内容
用户名:'email@gmail.com',
密码:“password”,
fromName:'Ssadd',//可选
答复:'email@gmail.com“,//可选
收件人:'email1@gmail.com,email2@gmail.com',
主题:'主题',
htmlBody:“标题正文”,
attachmentPaths:JSON.stringify(this.state.path),//
attachmentNames:JSON.stringify(this.state.filenames),//在android中是必需的,这些是原始文件的重命名。在ios中,文件名将与路径中指定的相同。在仅ios的应用程序中,无需定义它
})。然后((成功)=>console.log(成功));
};
this.state.path是一个数组,也是this.state.filename
我尝试了没有JSON.stringify的代码,但是我收到了带有附件的电子邮件,但是它们是空的,文件大小是0