tags:

views:

115

answers:

1

Hey,

I am designing an app in which the data is stored in the database. There's a button in the form which is on clicked to send an email to pre defined mail address with the data that is stored in the database. Since i am a newbie to android i need help regarding sending the mail... So please help me...

+2  A: 
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("plain/text");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{someEmailAddressString});
    intent.putExtra(Intent.EXTRA_SUBJECT, someSubjectString);
    intent.putExtra(Intent.EXTRA_TEXT, someEmailContentString);
    startActivity(intent);

This will open the email application with an email prepared with the above details. The user just has to hit 'send' to send the mail, then they'll be sent back to your app. This approach doesn't require any permissions in your application, and has good privacy implications because the user can see the mail before sending and has a record of it.

Jim Blackler
I have to get the values from database to the subject and text body of the email. can u please elaborate how to get it???
Rahul Varma
"get the values from database to the subject and text body of the email" .. well in the example 'someEmailContentString' should be replaced with some string obtained from your database to represent the body of the email. I can't advise further without knowing more about your database and how it works.
Jim Blackler
The scenario is this... i have to get values from 5 edit text views a date picker and a time picker.I must send an email gathering the information from them. I will be grateful if you explain how to get the info and send the mail. There's no problem if you can explain by using strings also...
Rahul Varma