如何调用在android平台上的电子邮件应用程序 [英] how to call email application in android platform

查看:149
本文介绍了如何调用在android平台上的电子邮件应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个意图发送电子邮件。在我们的应用
需要发送邮件,怎么可以调用的意图

there is an intent for "send an email." In our application needs to send mail, how can invoke that intent

推荐答案

您可以不要直接使用JavaMail API的版本,黑客发送一封电子邮件,但你可以很容易地让用户发送一个你使用Intent.ACTION_SEND为和意图选配。

You can't send an email directly without using a hacked version of the javamail apis, but you can easily have the user send one for you using Intent.ACTION_SEND and an Intent Chooser.

final Intent emailIntent = new Intent(Intent.ACTION_SEND); 
emailIntent.setType("text/plain"); 
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"webmaster@website.com"}); 
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "my subject"); 
emailIntent.putExtra(Intent.EXTRA_TEXT, "body text"); 
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));

请确保你是在实际设备上,当你测试这个code,因为它不会在模拟器中工作。

Make sure you're on an actual device when you test this code as it won't work from within the emulator.

这篇关于如何调用在android平台上的电子邮件应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆