简体   繁体   English

如何在后台将邮件发送到默认邮件帐户?

[英]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. 根据Till Helge Helwig建议,将发送邮件代码置于服务或AsyncTask中,现在无需使用Intent(无需用户交互)就可以发送邮件。

For this look at Sending Emails without User Intervention (no Intents) in Android 为此,请参阅在Android发送无需用户干预(无意图)的电子邮件

also Sending Email in Android using JavaMail API without using the default android app(Builtin Email application) 还可以使用JavaMail API在Android中发送电子邮件,而无需使用默认的android应用(内置电子邮件应用)

or Sending email without user interaction in Android . 在Android中无需用户交互即可发送电子邮件

Thanks. 谢谢。

you can get the default mail account via AccountManager class which contain the all the account which is associated with Account class 您可以通过AccountManager类获取默认的邮件帐户,该帐户包含与Account类关联的所有帐户

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;}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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