Android uses Gmail to send emails
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. );
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 );
}
}
});
}
}