Sending email on android via default email application

喜欢而已 提交于 2019-12-05 04:01:27

问题


I am developing an android application that can send email. This following code lets me send email from my default gmail app on android device. I was wondering what the classes i should set so that i can send email from default android mail application?

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmail");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "abc@gmail.com" });
sendIntent.setData(Uri.parse("abc@gmail.com"));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "enter subject");
sendIntent.setType("plain/text"); 
sendIntent.putExtra(Intent.EXTRA_TEXT, "Insert text");
startActivity(sendIntent);

回答1:


You don't have to. I am using following to send an email with default mail service.

        Uri uri = Uri.parse("mailto:info@yourcompany.com");
        Intent myActivity2 = new Intent(Intent.ACTION_SENDTO, uri);                                   
                    myActivity2.putExtra(Intent.EXTRA_SUBJECT,
                "Customer comments/questions");
        startActivity(myActivity2);


来源:https://stackoverflow.com/questions/8292503/sending-email-on-android-via-default-email-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!