我只是想在Android应用程序中发送电子邮件,我曾尝试过
下面是我的代码:
btnfeedbacksubmit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent Email = new Intent(Intent.ACTION_SEND);
Email.setType("text/email");
Email.putExtra(Intent.EXTRA_EMAIL, new String[] { "abc@gmail.com" });
Email.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
Email.putExtra(Intent.EXTRA_TEXT, "Hi");
startActivity(Intent.createChooser(Email, "Sending Feedback:"));
}
});
但它显示错误“没有应用可以执行此操作”
我还应该做些什么?
答案 0 :(得分:0)
试试这个:
Intent email = new Intent(Intent.ACTION_SEND);
email .setType("message/rfc822");
email .putExtra(Intent.EXTRA_EMAIL , "anemailaddress"});
email .putExtra(Intent.EXTRA_SUBJECT, "subject");
email .putExtra(Intent.EXTRA_TEXT , "sometext");
startActivity(Intent.createChooser(email , "Sending e-mail..."));
同时检查您是否安装了带默认帐户的电子邮件客户端。
答案 1 :(得分:0)
试试这段代码:
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto","abc@gmail.com", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "EXTRA_SUBJECT");
startActivity(Intent.createChooser(emailIntent, "Send email..."));