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
There is a pretty good example right on the AsyncTask doc page.
Pass your GMailSender
object in to an AsyncTask
, and call GMailSender#sendMail
during doInBackground
.
That is,
public void onClick(View v) {
final GMailSender sender = new GMailSender("username@gmail.com", "password");
new AsyncTask<Void, Void, Void>() {
@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);
}
}
}.execute();
}
public void onClick(View v) {
final GMailSender sender = new GMailSender("username@gmail.com", "password");
new AsyncTask<Void, Void, Void>() {
@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"