android 发送邮件代码
来源:互联网 发布:百度申诉 网络异常 编辑:程序博客网 时间:2024/05/21 21:39
Button bt5 = (Button) findViewById(R.id.Button05); bt5.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Setup the recipient in a String array String[] mailto = { "noam@gmail.com" }; // Create a new Intent to send messages Intent sendIntent = new Intent(Intent.ACTION_SEND); // Write the body of theEmail String emailBody = "You're password is: "; // Add attributes to the intent// sendIntent.setType("text/plain"); // use this line for testing // in the emulator sendIntent.setType("message/rfc822"); // use this line for testing // on the real phone sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Your Password"); sendIntent.putExtra(Intent.EXTRA_TEXT, emailBody); startActivity(sendIntent); } });