Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send emails from my Android application?

Tags:

android

email

I am developing an application in Android. I don't know how to send an email from the application?

like image 405
Rakesh Avatar asked Feb 04 '10 06:02

Rakesh


People also ask

Why can't I send emails from my Android phone?

If you can't send email try the following: Open your email application. Tap Menu and then Account Settings. If the settings are correct try setting the Security type to None and the Port to 25 or 587.


2 Answers

Use .setType("message/rfc822") or the chooser will show you all of the (many) applications that support the send intent.

like image 29
Jeff S Avatar answered Dec 04 '22 13:12

Jeff S


The best (and easiest) way is to use an Intent:

Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"[email protected]"}); i.putExtra(Intent.EXTRA_SUBJECT, "subject of email"); i.putExtra(Intent.EXTRA_TEXT   , "body of email"); try {     startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) {     Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } 

Otherwise you'll have to write your own client.

like image 98
Jeremy Logan Avatar answered Dec 04 '22 15:12

Jeremy Logan