我正在 Android 上制作电子邮件发送应用程序。当我通过单击按钮启动我的应用程序时,只有 To 字段可见。
为什么不显示 Cc、Bcc 和 Subject 字段?如何将这些字段添加到我的应用程序中?以及如何在“收件人”字段中显示默认电子邮件地址? (现在默认情况下,收件人字段中什么都不写。)
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();
}
});
最佳答案
intent.putExtra(Intent.EXTRA_CC, new String[] { "documents@4taxcash.com" });
你只需要将第二个参数设为字符串数组
关于android - 将 Cc、Bcc 和 Subject 字段添加到电子邮件发送 Android 应用程序中的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6234905/