如何识别电子邮件的收件人?
How can I identify the recipient of the email?
//Intent to gmail
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setData(Uri.parse("mailto:"));
//how can ı add this part
sendIntent.putExtra(Intent.EXTRA_EMAIL,fromEmail);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
sendIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
sendIntent.setType("text/plain");
try {
Intent shareIntent = Intent.createChooser(sendIntent, "Feedback");
startActivity(shareIntent);
Log.i("Finished sending email...", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
}
发件人工作正常,但我无法制作收件人。你能帮帮我吗?
不知道设计的怎么样。我也不确定您从哪里获得收件人电子邮件,但也许此代码对您有用。
public void contact() {
final Intent send = new Intent(Intent.ACTION_SENDTO);
final String email = "youremail@gmail.com";
final String subject = "subject";
final String body = "body...";
final String uriText = "mailto:" + Uri.encode(email) +
"?subject=" + Uri.encode(subject) +
"&body=" + Uri.encode(body);
final Uri uri = Uri.parse(uriText);
send.setData(uri);
startActivity(Intent.createChooser(send, getString(R.string.settings_email_chooser)));
}
//Intent to gmail
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setData(Uri.parse("mailto:"));
//how can ı add this part
sendIntent.putExtra(Intent.EXTRA_EMAIL,fromEmail);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
sendIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
sendIntent.setType("text/plain");
try {
Intent shareIntent = Intent.createChooser(sendIntent, "Feedback");
startActivity(shareIntent);
Log.i("Finished sending email...", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
}
发件人工作正常,但我无法制作收件人。你能帮帮我吗?
不知道设计的怎么样。我也不确定您从哪里获得收件人电子邮件,但也许此代码对您有用。
public void contact() {
final Intent send = new Intent(Intent.ACTION_SENDTO);
final String email = "youremail@gmail.com";
final String subject = "subject";
final String body = "body...";
final String uriText = "mailto:" + Uri.encode(email) +
"?subject=" + Uri.encode(subject) +
"&body=" + Uri.encode(body);
final Uri uri = Uri.parse(uriText);
send.setData(uri);
startActivity(Intent.createChooser(send, getString(R.string.settings_email_chooser)));
}