简体   繁体   中英

How to send mail in background to the default mail account?

I need to send a mail alerts in background when the application is running. Now i tried with intent but the the mail client activity is initialized but i need to send mail i background without the user knowledge. How can i make it possible.

As per Till Helge Helwig suggested put your sending mail code in service or in AsyncTask, Now without using Intent (Without user interaction) you can send mail.

For this look at Sending Emails without User Intervention (no Intents) in Android

also Sending Email in Android using JavaMail API without using the default android app(Builtin Email application)

or Sending email without user interaction in Android .

Thanks.

you can get the default mail account via AccountManager class which contain the all the account which is associated with Account class

hear some code to define, how to get the default account value

 Account[] accounts = AccountManager.get(this).getAccounts();
 for (Account account : accounts) {
   String possibleEmail = account.name;}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM