Wyślij E-Mail

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, "[email protected]");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");

startActivity(Intent.createChooser(intent, "Send Email"));

Powyższy kod otwiera okno dialogowe wyświetlające następujące aplikacje: - Bluetooth, Google Docs, Yahoo Mail, Gmail, Orkut, Skype itp.

Właściwie, chcę filtrować te opcje listy. Chcę wyświetlać tylko aplikacje związane z e-mailem, np. Gmail, Yahoo Mail. Jak to zrobić?

Widziałem taki przykład w aplikacji "Android Market".
  1. Otwarta aplikacja Android Market
  2. otwórz dowolną aplikację, w której programista podał swój adres e-mail. (Jeśli nie możesz znaleźć takiej aplikacji po prostu otwórz moja aplikacja: - rynek: / / szczegóły?id = combecomputer06pojazd.pamiętnik.za darmo, lub szukaj przez 'dziennik pojazdu')
  3. przewiń w dół do "deweloper"
  4. Kliknij "wyślij e-mail"

Okno dialogowe pokazuje tylko aplikacje e-mail, np. Gmail, Yahoo Mail itp. Nie pokazuje Bluetooth, Orkut itp. Jaki kod tworzy takie okno dialogowe?

Author: Charlie Brumbaugh, 2012-01-02

28 answers

Kiedy zmienisz swoje zamiary.setType jak poniżej otrzymasz

intent.setType("text/plain");

Użyj android.content.Intent.ACTION_SENDTO, aby uzyskać tylko listę klientów poczty e-mail, bez facebook lub innych aplikacji. Tylko Klienci poczty. Ex:

new Intent(Intent.ACTION_SENDTO);

Nie sugerowałbym, aby dostać się bezpośrednio do aplikacji e-mail. Pozwól użytkownikowi wybrać swoją ulubioną aplikację e-mail. Nie krępuj go.

Jeśli używasz ACTION_SENDTO, putExtra nie działa, aby dodać temat i tekst do intencji. Użyj Uri, aby dodać temat i treść tekst.

EDIT: Możemy użyć message/rfc822 zamiast "text/plain" jako typu MIME. Nie oznacza to jednak "tylko oferuj klientów poczty e-mail "- oznacza"oferuj wszystko, co obsługuje dane wiadomości/rfc822". To może łatwo obejmować niektóre aplikacje, które nie są klientami poczty e-mail.

message/rfc822 obsługuje typy MIME .mhtml, .mht, .mime

 185
Author: Padma Kumar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-09-29 04:08:30

Zaakceptowana odpowiedź nie działa na 4.1.2. Powinno to działać na wszystkich platformach:

Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
            "mailto","[email protected]", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Body");
startActivity(Intent.createChooser(emailIntent, "Send email..."));
Mam nadzieję, że to pomoże.

Update: zgodnie z marcwjj , wydaje się, że w 4.3, musimy przekazać tablicę łańcuchów zamiast łańcucha dla adresu e-mail, aby to działało. Być może będziemy musieli dodać jeszcze jedną linijkę:

intent.putExtra(Intent.EXTRA_EMAIL, addresses); // String[] addresses

Ref link

 783
Author: thanhbinh84,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 10:31:30

Istnieją trzy główne podejścia:

String email = /* Your email address here */
String subject = /* Your subject here */
String body = /* Your body here */
String chooserTitle = /* Your chooser title here */

1. Niestandardowe Uri:

Uri uri = Uri.parse("mailto:" + email)
    .buildUpon()
    .appendQueryParameter("subject", subject)
    .appendQueryParameter("body", body)
    .build();

Intent emailIntent = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(Intent.createChooser(emailIntent, chooserTitle));

2. Użycie Intent dodatków:

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

startActivity(Intent.createChooser(emailIntent, "Chooser Title"));

3. Biblioteka Wsparcia ShareCompat:

Activity activity = /* Your activity here */

ShareCompat.IntentBuilder.from(activity)
    .setType("message/rfc822")
    .addEmailTo(email)
    .setSubject(subject)
    .setText(body)
    //.setHtmlText(body) //If you are using HTML in your body text
    .setChooserTitle(chooserTitle)
    .startChooser();
 197
Author: Dipesh Rathod,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-09-02 15:20:16

To jest cytowane z Android official doc, Przetestowałem go na Androidzie 4.4, i działa idealnie. Zobacz więcej przykładów na https://developer.android.com/guide/components/intents-common.html#Email

public void composeEmail(String[] addresses, String subject) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    intent.putExtra(Intent.EXTRA_EMAIL, addresses);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}
 85
Author: marcwjj,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-05-01 14:04:35

późna odpowiedź, chociaż wymyśliłem rozwiązanie, które może pomóc innym

Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto: [email protected]"));
startActivity(Intent.createChooser(emailIntent, "Send feedback"));

To był mój wynik (Gmail + Skrzynka odbiorcza i nic więcej)

Tutaj wpisz opis obrazka

Otrzymałem to rozwiązanie od Google Developers site

 50
Author: capt.swag,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-02-03 13:01:08

Try:

intent.setType("message/rfc822");
 32
Author: Magnus,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-01-03 23:12:56

To działa dla mnie:

Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_EMAIL  , new String[] { "[email protected]" });
intent.putExtra(Intent.EXTRA_SUBJECT, "My subject");

startActivity(Intent.createChooser(intent, "Email via..."));

Tj. użyj akcji ACTION_SENDTO zamiast akcji {[2] }. Wypróbowałem go na kilku urządzeniach z Androidem 4.4 i ogranicza wyskakujące okienko wyboru, aby wyświetlać tylko aplikacje e-mail (e-mail, Gmail, Yahoo Mail itp.) i poprawnie wstawia adres e-mail i temat do wiadomości e-mail.

 27
Author: Adil Hussain,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-08-07 09:05:52

To jest sposób, aby to zrobić zgodnie z Android Developer Docs dodaj te linie kodu do swojej aplikacji:

Intent intent = new Intent(Intent.ACTION_SEND);//common intent 
intent.setData(Uri.parse("mailto:")); // only email apps should handle this

Jeśli chcesz dodać ciało i temat, dodaj to

intent.putExtra(Intent.EXTRA_SUBJECT, "Your Subject Here");
intent.putExtra(Intent.EXTRA_TEXT, "E-mail body" );
 18
Author: Avi Parshan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-03-04 19:16:50

Jeśli chcesz tylko klientów poczty, powinieneś użyć android.content.Intent.EXTRA_EMAIL z tablicą. Oto przykład:

final Intent result = new Intent(android.content.Intent.ACTION_SEND);
result.setType("plain/text");
result.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { recipient });
result.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
result.putExtra(android.content.Intent.EXTRA_TEXT, body);
 13
Author: Addev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-02-17 10:47:43

Poniższy kod działa dla mnie dobrze.

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"abc@gmailcom"});
Intent mailer = Intent.createChooser(intent, null);
startActivity(mailer);
 8
Author: Anam Ansari,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-05-04 05:37:42

Wreszcie wymyślić najlepszy sposób na zrobienie

    String to = "[email protected]";
    String subject= "Hi I am subject";
    String body="Hi I am test body";
    String mailTo = "mailto:" + to +
            "?&subject=" + Uri.encode(subject) +
            "&body=" + Uri.encode(body);
    Intent emailIntent = new Intent(Intent.ACTION_VIEW);
    emailIntent.setData(Uri.parse(mailTo));
    startActivity(emailIntent);
 8
Author: Ajay Shrestha,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-06-19 19:22:27

Edit: nie działa już z nowymi wersjami Gmaila

To był jedyny sposób, jaki znalazłem w tym czasie, aby to działało z dowolnymi postaciami.

Odpowiedź Doreamon jest teraz prawidłowa, ponieważ działa ze wszystkimi postaciami w nowych wersjach Gmaila.

Stara odpowiedź:


Tutaj jest mój. Wydaje się, że działa na wszystkich wersjach Androida, z obsługą tematu i treści wiadomości oraz pełną obsługą znaków utf-8: {]}
public static void email(Context context, String to, String subject, String body) {
    StringBuilder builder = new StringBuilder("mailto:" + Uri.encode(to));
    if (subject != null) {
        builder.append("?subject=" + Uri.encode(Uri.encode(subject)));
        if (body != null) {
            builder.append("&body=" + Uri.encode(Uri.encode(body)));
        }
    }
    String uri = builder.toString();
    Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
    context.startActivity(intent);
}
 6
Author: minipif,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-06-13 10:33:33

Żadne z tych rozwiązań nie działało dla mnie. Oto Minimalne rozwiązanie, które działa na Lizak. Na moim urządzeniu tylko Gmail i natywne aplikacje e-mail pojawiają się na wynikowej liście wyboru.

Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                                Uri.parse("mailto:" + Uri.encode(address)));

emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, body);
startActivity(Intent.createChooser(emailIntent, "Send email via..."));
 4
Author: scottt,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-05-13 01:35:12

Następujący kod zadziałał dla mnie!!

import android.support.v4.app.ShareCompat;
    .
    .
    .
    .
final Intent intent = ShareCompat.IntentBuilder
                        .from(activity)
                        .setType("application/txt")
                        .setSubject(subject)
                        .setText("Hii")
                        .setChooserTitle("Select One")
                        .createChooserIntent()
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
                        .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

activity.startActivity(intent);
 4
Author: Suyog Gunjal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-12-05 09:53:55

Działa na wszystkich wersjach Androida:

String[] TO = {"[email protected]"};
    Uri uri = Uri.parse("mailto:[email protected]")
            .buildUpon()
            .appendQueryParameter("subject", "subject")
            .appendQueryParameter("body", "body")
            .build();
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO, uri);
    emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
    startActivity(Intent.createChooser(emailIntent, "Send mail..."));
 4
Author: Usama Saeed US,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-03-21 23:54:43

U mnie działa idealnie:

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("mailto:" + address));
    startActivity(Intent.createChooser(intent, "E-mail"));
 3
Author: EpicPandaForce,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-12-22 08:59:36

Jeśli chcesz mieć pewność, że twoja intencja jest obsługiwana tylko przez aplikację e-mail (a nie inne wiadomości tekstowe lub aplikacje społecznościowe), użyj akcji ACTION_SENDTO i dołącz schemat danych "mailto:". Na przykład:

public void composeEmail(String[] addresses, String subject) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    intent.putExtra(Intent.EXTRA_EMAIL, addresses);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

Znalazłem to w https://developer.android.com/guide/components/intents-common.html#Email

 3
Author: Lamine Slimany,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-02-19 16:35:09

Większość z tych odpowiedzi działa tylko w przypadku prostego przypadku, gdy nie wysyłasz załącznika . W moim przypadku czasami muszę wysłać załącznik (ACTION_SEND) lub dwa załączniki (ACTION_SEND_MULTIPLE).

Więc wziąłem najlepsze podejścia z tego wątku i połączyłem je. Używa biblioteki ShareCompat.IntentBuilder, ale pokazuję tylko aplikacje, które pasują do action_sendto z uri " mailto:". W ten sposób otrzymuję tylko listę aplikacji e-mail z obsługą załączników:

fun Activity.sendEmail(recipients: List<String>, subject: String, file: Uri, text: String? = null, secondFile: Uri? = null) {
    val originalIntent = createEmailShareIntent(recipients, subject, file, text, secondFile)
    val emailFilterIntent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"))
    val originalIntentResults = packageManager.queryIntentActivities(originalIntent, 0)
    val emailFilterIntentResults = packageManager.queryIntentActivities(emailFilterIntent, 0)
    val targetedIntents = originalIntentResults
            .filter { originalResult -> emailFilterIntentResults.any { originalResult.activityInfo.packageName == it.activityInfo.packageName } }
            .map {
                createEmailShareIntent(recipients, subject, file, text, secondFile).apply { `package` = it.activityInfo.packageName }
            }
            .toMutableList()
    val finalIntent = Intent.createChooser(targetedIntents.removeAt(0), R.string.choose_email_app.toText())
    finalIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedIntents.toTypedArray())
    startActivity(finalIntent)
}

private fun Activity.createEmailShareIntent(recipients: List<String>, subject: String, file: Uri, text: String? = null, secondFile: Uri? = null): Intent {
    val builder = ShareCompat.IntentBuilder.from(this)
            .setType("message/rfc822")
            .setEmailTo(recipients.toTypedArray())
            .setStream(file)
            .setSubject(subject)
    if (secondFile != null) {
        builder.addStream(secondFile)
    }
    if (text != null) {
        builder.setText(text)
    }
    return builder.intent
}
 2
Author: David Vávra,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-01-06 17:31:09

Może powinieneś spróbować tego: intent.setType("plain/text");

Znalazłem to tutaj . Użyłem go w mojej aplikacji i pokazuje tylko Opcje E-Mail i Gmail.

 1
Author: sianis,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-01-02 13:54:43

Użyj tego:

boolean success = EmailIntentBuilder.from(activity)
        .to("[email protected]")
        .cc("[email protected]")
        .subject("Error report")
        .body(buildErrorReport())
        .start();

Użyj build gradle :

compile 'de.cketti.mailto:email-intent-builder:1.0.0'
 1
Author: Manish,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-10-24 11:33:50

To jest to, czego używam, i to działa dla mnie:

//variables
String subject = "Whatever subject you want";
String body = "Whatever text you want to put in the body";
String intentType = "text/html";
String mailToParse = "mailto:";

//start Intent
Intent variableName = new Intent(Intent.ACTION_SENDTO);
variableName.setType(intentType);
variableName.setData(Uri.parse(mailToParse));
variableName.putExtra(Intent.EXTRA_SUBJECT, subject);
variableName.putExtra(Intent.EXTRA_TEXT, body);

startActivity(variableName);

Pozwoli to również użytkownikowi wybrać preferowaną aplikację e-mail. Jedyną rzeczą, na którą to nie pozwala, jest ustawienie adresu e-mail odbiorcy.

 1
Author: grasshopper,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-01-03 19:20:48

Ten kod działa w moim urządzeniu

Intent mIntent = new Intent(Intent.ACTION_SENDTO);
mIntent.setData(Uri.parse("mailto:"));
mIntent.putExtra(Intent.EXTRA_EMAIL  , new String[] {"[email protected]"});
mIntent.putExtra(Intent.EXTRA_SUBJECT, "");
startActivity(Intent.createChooser(mIntent, "Send Email Using..."));
 1
Author: Mahen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-06-01 03:28:23

Jeśli chcesz kierować Gmail, możesz wykonać następujące czynności. Należy pamiętać, że intent to "ACTION_SENDTO", a nie "ACTION_SEND", A Dodatkowe pola intent nie są konieczne w Gmailu.

String uriText =
    "mailto:[email protected]" + 
    "?subject=" + Uri.encode("your subject line here") + 
    "&body=" + Uri.encode("message body here");

Uri uri = Uri.parse(uriText);

Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
if (sendIntent.resolveActivity(getPackageManager()) != null) {
   startActivity(Intent.createChooser(sendIntent, "Send message")); 
}
 1
Author: Prab,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-02-03 07:16:14

Skomponuj wiadomość e-mail w kliencie poczty e-mail:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" });
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(intent, ""));
 0
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-05-26 13:10:21
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                    "mailto", email, null));
            if (emailIntent.resolveActivity(context.getPackageManager()) != null) {
                context.startActivity(Intent.createChooser(emailIntent, "Send Email..."));
            } else {
                Toast.makeText(context, "No apps can perform this action.", Toast.LENGTH_SHORT).show();
            }
 0
Author: Ahamadullah Saikat,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-12-09 16:48:16

Używanie intent.setType("message/rfc822"); działa, ale pokazuje dodatkowe aplikacje, które niekoniecznie obsługują e-maile (np. GDrive). Używanie Intent.ACTION_SENDTO z setType("text/plain") jest najlepsze, ale musisz dodać setData(Uri.parse("mailto:")), Aby uzyskać najlepsze wyniki(tylko aplikacje e-mail). Pełny kod jest następujący:

    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setType("text/plain");
    intent.setData(Uri.parse("mailto:[email protected]"));
    intent.putExtra(Intent.EXTRA_SUBJECT, "Email from My app");
    intent.putExtra(Intent.EXTRA_TEXT, "Place your email message here ...");
    startActivity(Intent.createChooser(intent, "Send Email"));
 0
Author: Rami Alloush,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-08-27 23:16:15

Aktualizuję odpowiedź Adila w Kotlinie,

val intent = Intent(Intent.ACTION_SENDTO)
intent.data = Uri.parse("mailto:") // only email apps should handle this
intent.putExtra(Intent.EXTRA_EMAIL, Array(1) { "[email protected] })
intent.putExtra(Intent.EXTRA_SUBJECT, "subject")
if (intent.resolveActivity(packageManager) != null) {
    startActivity(intent)
} else {
    showSnackBar(getString(R.string.no_apps_found_to_send_mail), this)
}
 0
Author: KishanSolanki124,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-09-19 06:57:56

Użyj Anko-kotlin

context.email(email, subject, body)
 0
Author: Ali hasan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-09-22 13:10:34