Using AsyncTask to Send Android Email

后端 未结 2 1644
野趣味
野趣味 2020-12-11 05:18

I had recently asked a question regarding the following code:

Sending Email in Android using JavaMail API without using the default/built-in app

I had asked

2条回答
  •  -上瘾入骨i
    2020-12-11 05:46

    public void onClick(View v) {
    final GMailSender sender = new GMailSender("username@gmail.com",       "password");
    new AsyncTask() {
        @Override public Void doInBackground(Void... arg) {
            try {   
                sender.sendMail("This is Subject",   
                    "This is Body",   
                    "user@gmail.com",   
                    "user@yahoo.com");   
            } catch (Exception e) {   
                Log.e("SendMail", e.getMessage(), e);   
            } 
        return null;}
    }.execute();
    
    }
    

    Thank you "dokkaebi"

提交回复
热议问题