Sending email from gmail directly in android from my app without opening the gmail compose activity

∥☆過路亽.° 提交于 2019-12-11 09:29:13

问题


I am developing an android app where in an activity, I want to sent email.

Now the scenarios are: 1. The activity will send email only via the default gmail account of the android device. (No "Send via" picker will be shown) 2. the mail will automatically be sent without opening the gmail compose activity when I click on the SEND button of my Activity.

How can I do that ?

Additional question: is it possible to disable editing of send to, subject and email body of gmail from my app ?? if possible, then how ??


回答1:


follow the link that krishna suggested put your subject and body as a textview (not edittext)

and use in these lines:

GMailSender sender = new GMailSender("username@gmail.com", "password");
                sender.sendMail("My Subject That cannot be changed",   
                        "My Body That cannot be changed",   
                        "user@gmail.com",   
                        "user@yahoo.com");  

and follow all the steps suggested in this link: Sending Email in Android using JavaMail API without using the default/built-in app



来源:https://stackoverflow.com/questions/19700728/sending-email-from-gmail-directly-in-android-from-my-app-without-opening-the-gma

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