Code to send an email with attachments in Android

15 Aug

private void sendEmail()
txtTo = (MultiAutoCompleteTextView)findViewById(;
txtCc = (MultiAutoCompleteTextView)findViewById(;
txtBcc = (MultiAutoCompleteTextView)findViewById(;
mSubject = (EditText)findViewById(;
mMessageBody = (EditText)findViewById(;

String[] strTo = {txtTo.getText().toString()};
String[] strCc = {txtCc.getText().toString()};
String[] strBcc = {txtBcc.getText().toString()};
strSubject = mSubject.getText().toString();
strMessageBody = mMessageBody.getText().toString();


Intent objIntent = new Intent(android.content.Intent.ACTION_SEND);
objIntent.putExtra(android.content.Intent.EXTRA_EMAIL, strTo);
objIntent.putExtra(android.content.Intent.EXTRA_CC, strCc);
objIntent.putExtra(android.content.Intent.EXTRA_BCC, strBcc);
objIntent.setType(“plain/text”); objIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, strSubject);
objIntent.putExtra(android.content.Intent.EXTRA_TEXT, MESSAGE); objIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.parse(“file://”+Environment.getExternalStorageDirectory()+”/nikhil.html”));

Leave a comment

Posted by on August 15, 2011 in Android Source Code


Leave a Reply

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

You are commenting using your 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: