Android uses Gmail to send mail
1. [Code]sendmail.java
Package org.apache.android.mail;
Import android.app.Activity;
Import Android.os.Bundle;
Import Android.util.Log;
Import Android.view.View;
Import Android.widget.Button;
Import Android.widget.EditText;
public class SendMail extends Activity {
/**
* Called with the activity is first created.
*/
@Override
public void OnCreate (Bundle icicle) {
Super.oncreate (Icicle);
Setcontentview (R.layout.main);
Final Button send = (Button) This.findviewbyid (r.id.send);
Final EditText UserID = (EditText) This.findviewbyid (R.id.userid);
Final EditText password = (EditText) This.findviewbyid (R.id.password);
Final EditText from = (EditText) This.findviewbyid (R.id.from);
Final EditText to = (EditText) This.findviewbyid (r.id.to);
Final EditText subject = (EditText) This.findviewbyid (r.id.subject);
Final EditText BODY = (EditText) This.findviewbyid (r.id.body);
Send.setonclicklistener (New View.onclicklistener () {
public void OnClick (view view) {
Gmailsender sender = new Gmailsender (Userid.gettext (). toString (),
Password.gettext (). toString ());
try {
Sender.sendmail (Subject.gettext (). toString (),
Body.gettext (). toString (),
From.gettext (). toString (),
To.gettext (). toString ());
} catch (Exception e) {
LOG.E ("SendMail", E.getmessage (), E);
}
}
});
}
}