How can I create a simple program that it can send a text to a gmail
address?
I want to create a simple program that it have a EditText
and when I write some text in the EditText
and I click on the Button
, as the result the text be sent to a gmail address, for example to the example@gmail.com
. I know how to create a EditText
class but I do not know the operation post to the gmail
. Thank you.
Asked
Active
Viewed 49 times
1

android
- 91
- 9
-
possible duplicate of [Sending Email in Android using JavaMail API without using the default/built-in app](http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a) – Shabbir Dhangot Aug 04 '15 at 08:49
3 Answers
1
Standard way to do this is using the ACTION_SEND intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");
startActivity(Intent.createChooser(intent, "Send Email"));
If you want to send the mail in background without opening another app check this answer https://stackoverflow.com/a/2033124/2761055
1
In Android, you can use Intent.ACTION_SEND
to call an existing email client to send an Email.
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"put_your_mail@gmail.com"});
email.putExtra(Intent.EXTRA_SUBJECT, "subject");
email.putExtra(Intent.EXTRA_TEXT, "message");
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
For more details you visit How to send Email in Android and

IntelliJ Amiya
- 74,896
- 15
- 165
- 198
0
Here, you have information how to do that in background with PHP file on your server.
But in my opinion, this method is deprecated.
Look also here. This code will start new intent with email.

Pang
- 9,564
- 146
- 81
- 122

Eliasz Kubala
- 3,836
- 1
- 23
- 28