send data to email in background

后端 未结 3 1248
粉色の甜心
粉色の甜心 2020-12-19 14:16

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

相关标签:
3条回答
  • 2020-12-19 14:47

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

    BackgroundMail bm = new BackgroundMail(context);
    bm.setGmailUserName("yourgmail@gmail.com");
    bm.setGmailPassword("yourgmailpassword");
    bm.setMailTo("receiver@gmail.com");
    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

    0 讨论(0)
  • 2020-12-19 14:53

    This is one way of sending emails by using explicit email intent but this will not send in background

     Intent sendemai = new Intent(Intent.ACTION_SEND);
     sendemai.putExtra(Intent.EXTRA_EMAIL,
                            new String[] { toaddress });
     sendemai.putExtra(Intent.EXTRA_CC,
                            new String[] { emailadd }); 
     sendemai.putExtra(Intent.EXTRA_SUBJECT, sub);
     sendemai.putExtra(Intent.EXTRA_TEXT, body); 
     // need this to prompts email client only
     sendemai.setType("message/rfc822"); 
     startActivity(Intent.createChooser(payment_request,
                            "Select email application"));
    

    If you want to send in background then you need to provide some of user secure credentials.See Here

    0 讨论(0)
  • 2020-12-19 14:54

    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

    0 讨论(0)
提交回复
热议问题