0

I am developing an android app and i have a few edit texts and a submit button. On click of the submit button all the fields in the edit texts entered by the user should be sent to a particular email id. Could anyone please suggest me how it can be done?

enter image description here

Sujeet Sinha
  • 2,417
  • 2
  • 18
  • 27
  • Possible duplicate of [Send Email Intent](http://stackoverflow.com/questions/8701634/send-email-intent) – TapanHP Jul 10 '16 at 07:11

1 Answers1

0
String s = editText.getText().toString();

in button's onClickListner() method use this

    Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));
    emailIntent.setType("text/plain");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, s);
    //emailIntent.putExtra(Intent.EXTRA_HTML_TEXT, body); //If you are using HTML in your body text

    startActivity(Intent.createChooser(emailIntent, "Send Email via"));

Already answered Here

As you are working with multiple editTexts you can do this,

String s = (editText1.getText().toString() + "\n" + editText2.getText().toString() + "\n"+editText3.getText().toString() + "\n" + editText4.getText().toString() + "\n" + editText5.getText().toString() + "\n" + editText6.getText().toString() + "\n");

and then use same snippet as above.

If you want to know how send email without prior user interaction then see this answer

see this code snippet here also : https://github.com/enrichman/androidmail

There is also an API available named mandrillapp:

Read this blog for full code : https://www.mindstick.com/Articles/1673/sending-mail-without-user-interaction-in-android

Community
  • 1
  • 1
TapanHP
  • 5,969
  • 6
  • 37
  • 66
  • Hi, thanks for the answer, but the above code is opening the gmail app. I want the e mail id to be assigned to the button and send the details to the email with out the user knowing it. The email should be sent without opening the app.Please help. – susheel bharadwaj Jul 10 '16 at 07:16