Android 上的电子邮件活动

发布于 2024-11-07 08:40:08 字数 600 浏览 0 评论 0原文

我想从 Android 虚拟机发送电子邮件到我的 Gmail 帐户。 问题:但是按下发送按钮后我得到:

“没有应用程序可以执行此操作”

这是我的代码:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("audio/mp3");
//sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
//sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/download/test.mp3")); 
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(GlobalVariable.getstrEmail())); 
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
startActivity(Intent.createChooser(sendIntent, "Title:"));

I want to send email from Android virtual machine to my gmail account.
Problem: but on pressing send button I am getting:

"No application can perform this action"

Here is my code:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("audio/mp3");
//sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
//sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/download/test.mp3")); 
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(GlobalVariable.getstrEmail())); 
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
startActivity(Intent.createChooser(sendIntent, "Title:"));

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

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

发布评论

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

评论(3

东北女汉子 2024-11-14 08:40:08

在真实设备上尝试一下,它应该可以工作。并且您需要更改类型:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "body text");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));

Try it on a real device itself, it should work. And you need to change the type:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "body text");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
无需解释 2024-11-14 08:40:08

这可以帮助...

  Intent openEmailIntent = new Intent(android.content.Intent.ACTION_SEND);
  openEmailIntent.setType("plain/text");
  openEmailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                           new String[{"[email protected]"});
  openEmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"subject you want");
  openEmailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Any body ");
  this.startActivity(Intent.createChooser(openEmailIntent,"Sharing via Email"));

This can help...

  Intent openEmailIntent = new Intent(android.content.Intent.ACTION_SEND);
  openEmailIntent.setType("plain/text");
  openEmailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                           new String[{"[email protected]"});
  openEmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"subject you want");
  openEmailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Any body ");
  this.startActivity(Intent.createChooser(openEmailIntent,"Sharing via Email"));
梦里兽 2024-11-14 08:40:08

试试这个....

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);        
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{emailaddress});                                        
            startActivity(Intent.createChooser(emailIntent, "Send mail..."));

try this....

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);        
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{emailaddress});                                        
            startActivity(Intent.createChooser(emailIntent, "Send mail..."));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文