RSS

Code to send an email with attachments in Android

15 Aug

private void sendEmail()
{
txtTo = (MultiAutoCompleteTextView)findViewById(R.id.to);
txtCc = (MultiAutoCompleteTextView)findViewById(R.id.cc);
txtBcc = (MultiAutoCompleteTextView)findViewById(R.id.bcc);
mSubject = (EditText)findViewById(R.id.subject);
mMessageBody = (EditText)findViewById(R.id.message_content);

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

deleteFile();
createFile();

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”));
startActivity(objIntent);
finish();
}

Advertisements
 
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:

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: