2013-07-18 47 views
0
String body="message"; 

Intent emailIntent = new Intent(Intent.ACTION_SEND); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Check out this book I am reading"); 
emailIntent.setType("plain/text"); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); 
startActivity(Intent.createChooser(emailIntent, "Send email...")); 

无论我做什么(删除所有gmail帐户并使用邮件应用程序登录hotmail帐户),此代码默认启动Gmail,不显示或让我选择我的通用邮件应用程序。电子邮件意图默认启动gmail

因此,无法让用户通过hotmail或其他邮件提供商发送电子邮件。

更新: 其实这是代码,我曾经遇到过最好的一块,它直接向您提供的应用程序选择器只邮件客户端都存在哪里。下面的答案会给你一个巨大的应用程序列表,供选择,无关紧要。

String mailTo=""; 
Intent email_intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",mailTo, null)); 
email_intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject text here"); 
email_intent.putExtra(android.content.Intent.EXTRA_TEXT,"Body text here"); 

startActivity(Intent.createChooser(email_intent, "Send email...")); 

回答

2

尝试使用正确的MIME类型(text/plain)代替无效的MIME类型(plain/text)。

+0

谢谢你的工作。但是我提供了各种非邮件应用程序。我怎样才能过滤它们。 –

+1

@NubyJoe:你没有。 “ACTION_SEND”的要点是允许用户通过* format *(例如纯文本)共享内容。 *用户*可以控制何处,何时以及如何共享该内容。如果用户想将其作为推文发布,或将其上传到Dropbox,那是*用户的选择*,而不是你的。 “ACTION_SEND”不是“电子邮件”意图“”,不止是“ACTION_VIEW”是“浏览器”意图“”。 – CommonsWare

相关问题