我正在为酒店开发应用程序,在预订房间时,应用程序会向用户发送的电子邮件ID发送电子邮件。现在,我知道它会使用我的默认电子邮件客户端之一,这是Gmail。问题在于,它显示了gmail的撰写邮件窗口,邮件正文中显示了我的消息,但'to'字段为空。任何帮助?Android:Email'to'field empty
这里是代码:
public void sendmail(View vw)
{
name=et1.getText().toString();
to=et2.getText().toString();
phone=et3.getText().toString();
addr=et4.getText().toString();
Log.i("Send email", "");
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Thanks for using our app");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Hello mr"+name+"We just received an email with your details asking for a reservation:"+phone+" "+addr+"for room number"+x+"");
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
Log.i("Finished sending email...", "");
}
catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getBaseContext(), "There is no email client installed.", Toast.LENGTH_SHORT).show();
}
}
}
请提供[mcve],显示您正在使用的代码。 – CommonsWare