private EditText mEditText01;
private EditText mEditText02;
private EditText mEditText03;
private EditText mEditText04;
private Button mButton01;
private String[] strEmailReciver;
private String strEmailSubject;
private String[] strEmailCc;
private String strEmailBody;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.email);
mButton01 = (Button) findViewById(R.id.myButton1);
mEditText01 = (EditText) findViewById(R.id.myEditText1);
mEditText02 = (EditText) findViewById(R.id.myEditText2);
mEditText03 = (EditText) findViewById(R.id.myEditText3);
mEditText04 = (EditText) findViewById(R.id.myEditText4);
mButton01.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
/* 透过Intent来发送邮件 */
Intent mEmailIntent = new Intent(
android.content.Intent.ACTION_SEND);
/* 设定邮件格式为plain/text */
mEmailIntent.setType("plain/text");
/* 取得EditText01,02,03,04的值作为收件人地址,附件,主题,内容 */
strEmailReciver = new String[] { mEditText01.getText()
.toString() };
strEmailCc = new String[] { mEditText02.getText().toString() };
strEmailSubject = mEditText03.getText().toString();
strEmailBody = mEditText04.getText().toString();
/* 将取得的字符串放入mEmailIntent中 */
mEmailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
strEmailReciver);
mEmailIntent.putExtra(android.content.Intent.EXTRA_CC,
strEmailCc);
mEmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
strEmailSubject);
mEmailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
strEmailBody);
/* 开启Gmail 并将相关参数传入 */
startActivity(Intent.createChooser(mEmailIntent, "发信中..."));
}
});
}