Send email from Android application

20 10 2012

To handle standard Android share action (e.g. send email) application can call this dialog window, where user can choose share option:

‘Share’ dialog window

To do it, an Android application needs to send intent to Android OS:

public void shareCalculation(){
	Intent emailIntent = utils.prepareEmailIntent(getApplicationContext());
	startActivity(Intent.createChooser(emailIntent, getString(R.string.email_utils_chooseEmailClient)));
}

the prepareEmailIntent() method is as follows:

public Intent prepareEmailIntent(Context context) {
	Intent emailIntent = new Intent(Intent.ACTION_SEND);
	emailIntent.putExtra(Intent.EXTRA_EMAIL, getEmailsArray());		  
	emailIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.email_subject));
	emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(buildEmailMessage()));
	emailIntent.setType("text/html");

	return emailIntent;
}

 

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!


Actions

Information

Give Your feedback:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: