Send Email With only Email client application in android

寵の児 提交于 2020-01-02 15:08:45

问题


I want to implement an option to send email. Right now i can send email but problem is, Android shows many applications to send such as bluetooth, facebook, message,etc which is not required. I need to avoid this and show only email client application.

Intent intent = new Intent(Intent.ACTION_SEND); 
String[] emails = {"suresh.chandani@gmail.com"}; 
intent.putExtra(Intent.EXTRA_EMAIL, emails); 
intent.putExtra(Intent.EXTRA_STREAM, uri); 
intent.putExtra(Intent.EXTRA_SUBJECT, "Test App"); 
intent.putExtra(Intent.EXTRA_TEXT, "Email Body"); 
intent.setType("message/rfc822"); 
startActivity(intent);

If any one knows to how to achieve this please let me know


回答1:


Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:suresh.chandani@gmail.com);    
intent.putExtra(Intent.EXTRA_SUBJECT, "Test App");  
intent.putExtra(Intent.EXTRA_TEXT, "Email Body");
startActivity(intent);

Credit goes to Adams Bros Blogs but he does mention in his post that this only worked for gmail for him. See if you have any success with it. He does show another way of doing this that worked for him.




回答2:


To send email to a specific address, use ACTION_SENDTO and a mailto: Uri in your Intent supplied to startActivity(). Or, implement your own email client, using the JavaMail port for Android.



来源:https://stackoverflow.com/questions/11672002/send-email-with-only-email-client-application-in-android

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