发送电​​子邮件Android中 [英] Sending e-Mail in Android

查看:131
本文介绍了发送电​​子邮件Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我的Andr​​oid应用程序发送电子邮件。所以,我送2个参数(电子邮件和主题)的电子邮件客户端应用程序,但是当应用程序打开的电子邮件客户端,只有受加参数和电子邮件参数没有设置。

我该如何解决这个问题?

 字符串getMail = email.toString();
  Log.d(GET MAIL:getMail);
  字符串主题=主题;
  意图emailIntent =新意图(Intent.ACTION_SEND);
  emailIntent.putExtra(Intent.EXTRA_EMAIL,getMail);
  emailIntent.putExtra(Intent.EXTRA_SUBJECT,学科);//需要这个提示仅电子邮件客户端
 emailIntent.setType(信息/ RFC822);
 startActivity(Intent.createChooser(emailIntent,选择电子邮件客户端));


解决方案

修改 emailIntent.putExtra(Intent.EXTRA_EMAIL,getMail);

  emailIntent.putExtra(Intent.EXTRA_EMAIL,新的String [] {getMail});

I need to send an e-mail from my Android application. So, I send 2 parameters ( e-mail and subject) to the e-mail client app, but when app opens e-mail client, there is only subject parameter added, and email parameter is not set.

How I can fix this?

  String getMail = email.toString();
  Log.d("GET MAIL:",getMail);
  String subject = "Subject";
  Intent emailIntent = new Intent(Intent.ACTION_SEND);
  emailIntent.putExtra(Intent.EXTRA_EMAIL, getMail);
  emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);

// need this to prompts email client only                                                
 emailIntent.setType("message/rfc822");
 startActivity(Intent.createChooser(emailIntent,"Choose E-mail client:"));

解决方案

Change emailIntent.putExtra(Intent.EXTRA_EMAIL, getMail);

to:

emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{getMail});

这篇关于发送电​​子邮件Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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