0

I want to email some credentials to a specific email address. From what email address will this mail be sent?

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL  , new
String[]{"recipient@example.com"}); 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();
}

Who is the sender here?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Bamadeva
  • 335
  • 2
  • 10
  • 21

2 Answers2

1

This intent will open the mail clients available in your device. Then its up to you to add sender email ID. Or it will take default email ID if you have already logged in.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
  • Thanks 4 ur answer ! Shad But the thing is every user is not to give/add the email because admin will send the user name and the password through the app getting the email from the user. Can u clarify a bit more please and it would b appreciate !! – Bamadeva Dec 17 '12 at 06:49
  • 1
    If you have to use same email Id, then you will have to go with Java mail approach. Check this: http://stackoverflow.com/questions/5962040/setting-the-sender-of-an-email-using-startactivitymailintent – MysticMagicϡ Dec 17 '12 at 06:55
  • 2
    The Intent (Intent.Action_SEND) will show a pop up containing possible ways (possible list of applications) through which you can send an email.You can choose from the list available. For example, If you choose Gmail app, it would open in a new mail page, with data's such as 'to', 'subject', 'body' already filled in. Provided you have given the details in the intent. For your second question, The sender's email address would be the email id registered in the email client. That means, you would have used some email to login youy email app in your mobile. That id would be the sender's email id. –  Dec 17 '12 at 06:58
1

You should use JavaMail Api for this You can send & access email with the help of this:-- Check this!

& here is the library!

Community
  • 1
  • 1
Deepanker Chaudhary
  • 1,694
  • 3
  • 15
  • 35