Before Proceeding to deal with Sending Emails in Android. Let us see first,
What is Intent?
Intents are asynchronous messages which help us to activate the Components such as Activities,
Services, Board cast Receivers.
The Core Components of the Application are invoked by Intents.
In other words Intent is a horde of Information which contains the Action, Data’s involved in the
Action, and the Category of the Component.
Use Intents, as shown below, write the following code in the button click event, if you want to send a mail to
a user, when the user hits Email Button.
// Creating a Object for the Class Intent
Intent sendIntent;
// Since we want to send ,we are using ACTION_SEND
sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("application/octet-stream");
sendIntent.putExtra(Intent.EXTRA_EMAIL,new String[] {"san123@gmail.com"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Test");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Hy Testing");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));
sendIntent.setType("image/jpeg");
startActivity(Intent.createChooser(sendIntent, "Send Mail"));
Intents are asynchronous messages which help us to activate the Components such as Activities,
Services, Board cast Receivers.
The Core Components of the Application are invoked by Intents.
In other words Intent is a horde of Information which contains the Action, Data’s involved in the
Action, and the Category of the Component.
Use Intents, as shown below, write the following code in the button click event, if you want to send a mail to
a user, when the user hits Email Button.
// Creating a Object for the Class Intent
Intent sendIntent;
// Since we want to send ,we are using ACTION_SEND
sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("application/octet-stream");
sendIntent.putExtra(Intent.EXTRA_EMAIL,new String[] {"san123@gmail.com"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Test");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Hy Testing");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));
sendIntent.setType("image/jpeg");
startActivity(Intent.createChooser(sendIntent, "Send Mail"));
No comments:
Post a Comment