0

How to send mail through only email clients from my android application.

I am using the below code in my application but its opeing messeges and bluetooth also. I need only Email clients like Gmail or yahoo.

  Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/rfc822");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "mailto@gmail.com");
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My subject");
    startActivity(Intent.createChooser(emailIntent, "Email:"))
Hardik Joshi
  • 9,477
  • 12
  • 61
  • 113

4 Answers4

2

Just Go on to Use this Code...It will always invoke your default Email Client.

Intent intent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + subject + "&body=" + body);
intent.setData(data);
startActivity(intent);
Haresh Chaudhary
  • 4,390
  • 1
  • 34
  • 57
0

Is this of any help? This one is using the gmail client it seems.

Intent URI to launch Gmail App

Community
  • 1
  • 1
Spetastium
  • 205
  • 3
  • 12
0

I use this way to avoid choosing other app but default email client.

Intent it = new Intent(Intent.ACTION_SEND);
it.setType("text/plain");
it.putExtra(Intent.EXTRA_EMAIL, new String[]{emailAddr});
it.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
it.putExtra(Intent.EXTRA_TEXT, emailContent);
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + emailAddr));
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ActivityInfo info = emailIntent.resolveActivityInfo(mContext.getPackageManager(), PackageManager.MATCH_DEFAULT_ONLY);
if (info != null) {
    it.setPackage(info.packageName);
}

mContext.startActivity(it);

I hope it can help you ~

heheBear
  • 236
  • 2
  • 6
-1

I made it work using this:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("mp3/3gp");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "recording voice");
Uri eri=Uri.parse(rlm.getPlayList().get(position).get("songPath"));
emailIntent.putExtra(Intent.EXTRA_STREAM,eri);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "hello, it is the recorded file of our conversassion");
emailIntent.putExtra(Intent.EXTRA_STREAM,rlm.getPlayList().get(position).get("songPath") );
RecordedList.this.startActivity(Intent.createChooser(emailIntent, "Send Email"));
Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Sujeet Kumar Mehta
  • 2,761
  • 2
  • 20
  • 28