How to open gmail in android

Faran Tariq :

I just wanted to open the Gmail app through my app and wanted to set email, subject and message from my application.

I have tried GmailService but it is not supporting bcc or cc emails. Link: https://github.com/yesidlazaro/GmailBackground

BackgroundMail.newBuilder(this)
    .withUsername("[email protected]")
    .withPassword("password12345")
    .withMailto("[email protected]")
    .withType(BackgroundMail.TYPE_PLAIN)
    .withSubject("this is the subject")
    .withBody("this is the body")
    .withOnSuccessCallback(new BackgroundMail.OnSuccessCallback() {
        @Override
        public void onSuccess() {
            //do some magic
        }
    }).withOnFailCallback(new BackgroundMail.OnFailCallback() {
        @Override
        public void onFail() {
            //do some magic
        }
    }).send();

I would like to use bcc and cc functionality along with the attachment, subject, and message.

Priyankagb :

open gmail via Intent

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("[email protected]"));
intent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
intent.putExtra(Intent.EXTRA_CC, new String[]{"[email protected]"});
intent.putExtra(Intent.EXTRA_BCC, new String[]{"[email protected]"});
intent.putExtra(Intent.EXTRA_SUBJECT, "your subject goes here...");
intent.putExtra(Intent.EXTRA_TEXT, "Your message content goes here...");

startActivity(intent);

just pass EXTRA_CC & EXTRA_BCC in intent argument

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=91049&siteId=1
Recommended