【发布时间】:2018-05-29 16:50:06
【问题描述】:
我正在使用 npm pacakge 打开带有数据的邮件客户端: https://www.npmjs.com/package/react-native-mail-compose
另外,我正在使用他们的例子:
import MailCompose from 'react-native-mail-compose';
// later in your code...
async sendMail() {
try {
await MailCompose.send({
toRecipients: ['to1@example.com', 'to2@example.com'],
ccRecipients: ['cc1@example.com'],
bccRecipients: ['bcc1@example.com', 'bcc2@example.com'],
subject: 'This is subject',
text: 'This is body',
html: '<p>This is <b>html</b> body</p>', // Or, use this if you want html body. Note that some Android mail clients / devices don't support this properly.
attachments: [{
filename: 'mytext', // [Optional] If not provided, UUID will be generated.
ext: '.txt',
mimeType: 'text/plain',
text: 'Hello my friend', // Use this if the data is in UTF8 text.
data: '...BASE64_ENCODED_STRING...', // Or, use this if the data is not in plain text.
}],
});
} catch (e) {
// e.code may be 'cannotSendMail' || 'cancelled' || 'saved' || 'failed'
}
}
并在按钮按下时调用此函数。所有数据都OK,除了body,比如Subject里面有“This is subject”,邮件客户端的CC里面有“cc1@example.com”,但是body总是空的,我在邮件客户端中看不到“这是正文”。
【问题讨论】:
标签: javascript reactjs email react-native