From: Asheesh Arya <asheesharya...@gmail.com>
Date: Mon, 17 Sep 2012 11:24:50 +0530
Local: Mon, Sep 17 2012 1:54 am
Subject: Re: [android-developers] hi...
this is the code to send a mail with attachment
Button send;
EditText address, subject, emailtext;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main11);
send = (Button) findViewById(R.id.emailsendbutton);
address = (EditText) findViewById(R.id.emailaddress);
subject = (EditText) findViewById(R.id.emailsubject);
emailtext = (EditText) findViewById(R.id.emailtext);
final TextView tv = (TextView)findViewById(R.id.fileContent);
send.setOnClickListener(new OnClickListener() {
// TextView tv = (TextView)findViewById(R.id.fileContent);
// TODO Auto-generated method stub
if(!address.getText().toString().trim().equalsIgnoreCase("")){
File dir = Environment.getExternalStorageDirectory();
try {
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
emailIntent.putExtra(Intent.EXTRA_STREAM,
sendemail.this.startActivity(Intent
} catch (Throwable t) {
Toast.makeText(sendemail.this, "Request failed: " +
xml file
<?xml version="1.0" encoding="utf-8"?>
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:width="170dip"
android:id="@+id/emailaddress"></EditText>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/emailaddress"
android:text="Email address"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout03"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:width="170dip"
android:id="@+id/emailsubject"></EditText>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/emailsubject"
android:text="Subject"></TextView>
</LinearLayout>
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:lines="5"
android:id="@+id/emailtext"></EditText>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/emailsendbutton"
android:text="Send!" android:width="150dip"></Button>
</LinearLayout>
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||