如何在android中自动发送邮件图片

时间:2014-11-08 06:00:30

标签: android image email camera

我正在开发一个应用程序,我想在捕获图像后自动点击图像,应用程序应该将图片发送到邮件。

Intent shareIntent = new Intent(Intent.ACTION_SEND); 
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imgSaved));
shareIntent.setType("image/*"); 
startActivity(Intent.createChooser(shareIntent, "Share Image"));

2 个答案:

答案 0 :(得分:1)

您需要创建一个在选择图像时触发的意图

Intent intent = new Intent(android.content.Intent.ACTION_SEND); 
intent.setType("application/image");
intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail}); 
intent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Any subject you want to give"); 
intent.putExtra(android.content.Intent.EXTRA_TEXT, "text you want"); 
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/imageYouSelected.jpeg"));
startActivity(Intent.createChooser(emailIntent, "sending youer email"));

您可以使用 JAVA API 方法,例如here

答案 1 :(得分:0)

尝试这样可以帮到你,

Intent shareIntent = new Intent(Intent.ACTION_SEND); 
shareIntent.putExtra(Intent.EXTRA_EMAIL,
                new String[] { "aa@gmail.com" });
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "text of email"); 
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imgSaved));
shareIntent.setType("image/*"); 
startActivity(Intent.createChooser(shareIntent, "Share Image"));