我正在Android上发送电子邮件发送应用程序。当我通过点击按钮启动我的应用程序时,只有To字段可见。
为什么不显示抄送,密送和主题字段?如何将这些字段添加到我的应用程序?以及如何在“收件人”字段中显示默认电子邮件地址? (现在默认情况下,没有任何内容写入“收件人”字段。)
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
clickBtn = (Button) findViewById(R.id.sendemail);
clickBtn.setText("Send email");
clickBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { "user@fakehost.com","user2@fakehost.com" };
String aEmailCCList[] = { "user3@fakehost.com","user4@fakehost.com"};
String aEmailBCCList[] = { "user5@fakehost.com" };
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
emailIntent.putExtra(android.content.Intent.EXTRA_CC, aEmailCCList);
emailIntent.putExtra(android.content.Intent.EXTRA_BCC, aEmailBCCList);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My subject");
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "My message body.");
startActivity(emailIntent);
//startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
}
});
答案 0 :(得分:21)
intent.putExtra(Intent.EXTRA_CC, new String[] { "documents@4taxcash.com" });
您只需将第二个参数设为字符串数组
答案 1 :(得分:0)
EXTRA_CC已过时 但是这样可以解决:
...
intent.setData(Uri.parse(“ mailto:someone@theirsite.com?cc=someoneelse@theirsite.com”));
...