Wednesday, July 27, 2011

how to send an email

The snippet helps to send email from your android mobile.

Using this intent it will list a list of mail clients that are available to handle this intent.

If we select one of them then it will send email using that mail client.

Example.
 Intent emailIntent = new Intent(Intent.ACTION_SEND);
//Message Type
emailIntent.setType("text/image");

//To Address. Here strArrTo is an string array
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, strArrTO);

//CC . Here strArrCC is an string array
emailIntent.putExtra(android.content.Intent.EXTRA_CC, strArrCC);

//BCC. Here strArrBCC is an string array
emailIntent.putExtra(android.content.Intent.EXTRA_BCC, strArrBCC);

//Subject line. Here strSUB is string
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, strSUB);

//Body..Here strMes is string
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, strMes);

//Starting Intent...
startActivity(emailIntent);

No comments:

Post a Comment