Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Cc, Bcc and Subject fields to a message in an email sending Android app

Tags:

android

I am making an email sending application on Android. Only To field is visible when I launch my application through a button click.

Why doesn’t it show Cc, Bcc and Subject fields? How to add these fields to my app? And how to show a default email address in the To field? (Now nothing is written in the To field by default.)

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[] = { "[email protected]","[email protected]" };
        String aEmailCCList[] = { "[email protected]","[email protected]"};
        String aEmailBCCList[] = { "[email protected]" };
        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();
    }
});
like image 779
atul yadav Avatar asked Jun 04 '11 05:06

atul yadav


People also ask

How do you include a CC in an email?

Hit "Compose" to begin a new email, or click on the email thread that you want to reply to and select "Reply" to write a response. 3. If you're typing a new message, the "CC" option will appear to the right of the "To" field. Click "CC" to open up the CC field, and type in the recipient's email address.

How do you use CC and BCC in email?

Cc means carbon copy and Bcc means blind carbon copy. For emailing, you use Cc when you want to copy others publicly, and Bcc when you want to do it privately. Any recipients on the Bcc line of an email are not visible to others on the email.


1 Answers

intent.putExtra(Intent.EXTRA_CC, new String[] { "[email protected]" });

You just had to make the second parameter a string array

like image 126
user2744794 Avatar answered Sep 19 '22 12:09

user2744794