0

I am having an android form and one of the field is Email ID.I want take that email id and send some data on that email id on the click of a button on the same activity. What are the possible ways by which we can send the data.

Jagdeep Singh
  • 1,200
  • 1
  • 16
  • 34
  • Yes I want to send the email that is written in the EditBox on the click of a button. – Jagdeep Singh May 14 '12 at 07:20
  • you can refer Dheeresh Singh 's answer if you any doubt in that let me know – KMI May 14 '12 at 07:25
  • In that example,data has been send to a particular email ID .But i want to send the data(Of my own) to the email ID that the user enter in the EditText. – Jagdeep Singh May 14 '12 at 15:05
  • there are two examples which one you have tried using sending mail intent or using javamail api? – KMI May 15 '12 at 04:19

2 Answers2

2

it's very easy to send an Email with data taken from an EditText

String mail = "this is the Email message body";
i = new Intent(Intent.ACTION_SEND); // start the activity for sending an email
i.setType("vnd.android.cursor.dir/email"); //set the mime type for the Email
i.putExtra(android.content.Intent.EXTRA_SUBJECT, "FW: " + "subject");
String[] to = {editText.getText().toString()};
i.putExtra(android.content.Intent.EXTRA_EMAIL, to);

i.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(mail));
startActivity(Intent.createChooser(i, "EMAIL"));
thepoosh
  • 12,497
  • 15
  • 73
  • 132
0

there are 2 ways

1- using native email app Intent intent = new Intent(Intent.ACTION_SEND); it will open the screen with data pre-filled in form. You have to send data in intent.

2- Send without native app

Sending Email in Android using JavaMail API without using the default/built-in app

Community
  • 1
  • 1
Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36