我正在爲酒店開發應用程序,在預訂房間時,應用程序會向用戶發送的電子郵件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