android - 将 Cc、Bcc 和 Subject 字段添加到电子邮件发送 Android 应用程序中的消息

标签 android

我正在 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/

相关文章:

android - TabHost 和 ActionBar

java - 无法使用 Firebase ML Kit 读取更多 30 个字符的条形码

java - 异步任务流程

java - 如何使用游标从 sqlite 表中获取整个列?

android - 如何使用链式工作人员使用工作管理器创建定期请求

android - 从内存下载并安装应用程序 (apk) - 无需 SD 卡

android - ProgressBar 在 android 中的 Activity 之间?

android - Listview 替换第一个项目而不是创建新项目

android - 通知图标不显示在 Lollipop 的状态栏中

android - 在 Xamarin BaseAdapter 中寻找清除方法