这个问题在这里已有答案:
假设我在布局中有一个按钮和一个编辑文本。我如何向android地址中的编辑文本发送一封说明该地址的邮件的电子邮件?
String email = editText.getText().toString();
Intent intent = new Intent(Intent.ACTION_SENDTO,
Uri.parse("mailto:" + email));
intent.putExtra(Intent.EXTRA_SUBJECT, "Enter subject here");
intent.putExtra(Intent.EXTRA_TEXT, "Enter email body here");
startActivity(Intent.createChooser(intent,
"Choose email client")));
首先从您的电子邮件edittext获取文本。然后使用此电子邮件向您发送电子邮件。
String email = emailfield.getText().toString()
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , email);
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MyActivity.this, "No email clients installed.", Toast.LENGTH_SHORT).show();
}