is it possible that I send email in background using service.. like in service I use Intent with ACTION_SENDTO with Uri data mailto:recipient_email and it get sent in the background without any user intervention .. or through default email app without prompting the user ...
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
Then you need to do it programmatically. Here's a tutorial for that http://nilvec.com/sending-email-without-user-interaction-in-android/
The best solution is using the Gmail account to send the email.
Generally speaking:
here's the code
this code was originally posted here Javamail api in android using XOauth.
Please note to get the OAuth token you need an Activity and you have to ask the user which account to use. The token should be retrieved during the OnCreate phase and saved in the preferences. See also How to get the Android device's primary e-mail address
Alternatively you can use mail.jar but you have to ask the user for their username and password.
Send e-mail in Android using the JavaMail API using Gmail authentication
Steps to create a sample Project:
MailSenderActivity.java
GMailSender.java
JSSE Provider
JSSEProvider.java
ADD 3 jars found in the following link to your Android Project
Click here - How to add External Jars
And Don't forget to add this line in your manifest:
Run the project and check your recipient mail account for the mail. Cheers!!
Hope this helps
P.S. And don't forget that you cannot do network operation from any Activity in android. Hence it is recommended to use
AsyncTask
orIntentService
to avoid network on main thread exception.Jar files : https://code.google.com/p/javamail-android/