2

当我单击一个按钮时,我使用以下代码来启动一封电子邮件并用来自数据库查询的数据填充它。

问题是,在单击按钮时弹出的“发送邮件...”对话框中,它仅提供以下选项:

* Evernote - create note
* Gmail
* Skype

我需要通过我的工作 Microsoft Exchange 服务器(我的主要电子邮件客户端)发送此信息,但不提供此功能(但是,当我单击其他应用程序中的 Web 超链接或类似按钮时,它会提供):

private void sendEmail(String recipient, String subject, String message) { 
    try { 
        final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
        emailIntent.setType("plain/text"); 
        if (recipient != null)  emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{recipient}); 
        if (subject != null)    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); 
        if (message != null)    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message); 

        startActivity(Intent.createChooser(emailIntent, "Send mail...")); 

    } catch (ActivityNotFoundException e) { 
        // cannot send email for some reason 
    } 
}

有任何想法吗?

4

2 回答 2

2

好的,所以我在这篇文章中找到了答案:如何通过 Intents 打开电子邮件程序(但只有一个电子邮件程序)

更改 MIME 类型就是答案,这就是我在我的应用程序中所做的以更改相同的行为。我用了 intent.setType("message/rfc822");

像梦一样工作!

于 2012-12-18T16:50:46.630 回答
0

When the screen pops up and you have the option to choose the application you need to send data, at that time select "Set Default Action". So, next time you use your app to send the email it will open the default application you selected

于 2014-08-02T07:36:29.403 回答