Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send data to email in background

I am working on sending my message data on my email Id.I have made a mainActivity class containing an editText (for emailId) and a Button. Another class is BroadcastReceiver class in which I retrieve data. Now I can't understand how to send that data to the provided email in Background. I have googled a lot but can't get the required response. Please share the ideas and help me in it.

like image 501
Anjali Avatar asked Jan 12 '23 22:01

Anjali


2 Answers

I create open source library for this. Usage is very simple:

BackgroundMail bm = new BackgroundMail(context);
bm.setGmailUserName("[email protected]");
bm.setGmailPassword("yourgmailpassword");
bm.setMailTo("[email protected]");
bm.setFormSubject("Subject");
bm.setFormBody("Body");
bm.send();

With this permissions

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/> 

You can download it here: https://github.com/kristijandraca/BackgroundMailLibrary

like image 59
Kristijan Drača Avatar answered Jan 18 '23 05:01

Kristijan Drača


In android, You can send Email with explicit email intent however it will show a email screen and will not allow to send data in background.

To send data in background, you can use java mail api to send the mail.

Take a look on this http://www.tutorialspoint.com/java/java_sending_email.htm

like image 44
Connecting life with Android Avatar answered Jan 18 '23 05:01

Connecting life with Android