反应本机打开默认邮件应用程序与附件

发布于 2025-01-16 01:12:39 字数 202 浏览 2 评论 0原文

我需要能够通过单击反应本机应用程序中的按钮来打开默认电子邮件应用程序。我尝试使用 react-native-email-link 但它没有添加附件的选项。我还可以使用其他允许附件的东西吗?

I need to be able to open the default email app on the click of a button from a react native application. I tried using react-native-email-link but it does not have the option of adding attachments. Is there something else I can use that will allow attachments?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终陌 2025-01-23 01:12:39

您可以通过 expo-mail-composer 实现此目的

    import * as MailComposer from 'expo-mail-composer';

    [...]

    const canMail = await MailComposer.isAvailableAsync();

    if(!canMail) {
      console.warn("Can't open the mail app! You may be using the iPhone simulator or don't have a mail app installed")
      return;
    }

    MailComposer.composeAsync({
      subject: "Hello, Mail Composer!",
      body: "Some body text goes here",
      recipients: "[email protected]",
      attachments: [
        "https://venturebeat.com/wp-content/uploads/2017/09/stack_overflow_logo.jpg?w=1200&strip=all"
        // you can also attach local files
      ]
    });

:此处的小吃演示:https://snack.expo.dev/@joem-rp/expo-mail-composer-demo

You can likely achieve this with expo-mail-composer:

    import * as MailComposer from 'expo-mail-composer';

    [...]

    const canMail = await MailComposer.isAvailableAsync();

    if(!canMail) {
      console.warn("Can't open the mail app! You may be using the iPhone simulator or don't have a mail app installed")
      return;
    }

    MailComposer.composeAsync({
      subject: "Hello, Mail Composer!",
      body: "Some body text goes here",
      recipients: "[email protected]",
      attachments: [
        "https://venturebeat.com/wp-content/uploads/2017/09/stack_overflow_logo.jpg?w=1200&strip=all"
        // you can also attach local files
      ]
    });

Working Snack demo here: https://snack.expo.dev/@joem-rp/expo-mail-composer-demo

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文