Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call email application in android platform

Tags:

android

there is an intent for “send an email.” In our application needs to send mail, how can invoke that intent

like image 561
deepthi Avatar asked Jan 22 '23 22:01

deepthi


1 Answers

You can't send an email directly without using a hacked version of the javamail apis, but you can easily have the user send one for you using Intent.ACTION_SEND and an Intent Chooser.

final Intent emailIntent = new Intent(Intent.ACTION_SEND); 
emailIntent.setType("text/plain"); 
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); 
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "my subject"); 
emailIntent.putExtra(Intent.EXTRA_TEXT, "body text"); 
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));

Make sure you're on an actual device when you test this code as it won't work from within the emulator.

like image 94
emmby Avatar answered Feb 04 '23 02:02

emmby