【问题标题】:React Native - Open mail client with bodyReact Native - 使用正文打开邮件客户端
【发布时间】: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


    【解决方案1】:

    我已经用另一个包react-native-send-intent 修复了它。 它就像一个魅力! :)

    【讨论】:

      【解决方案2】:

      我明白了,试试这个包。 https://github.com/anarchicknight/react-native-communications 使用起来非常简单

      【讨论】:

      猜你喜欢
      • 2015-07-16
      • 2020-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-26
      • 1970-01-01
      • 2010-09-29
      相关资源
      最近更新 更多