Skip to content

Instantly share code, notes, and snippets.

@RohanNavlakhe2
Last active January 2, 2022 13:41
Show Gist options
  • Save RohanNavlakhe2/52082de0973abc87ff3cdc90d7220904 to your computer and use it in GitHub Desktop.
Save RohanNavlakhe2/52082de0973abc87ff3cdc90d7220904 to your computer and use it in GitHub Desktop.
public class SendMailAsynchronously extends AsyncTask<String,String,String>
{
private Context context;
public SendMailAsynchronously(Context context)
{
this.context=context;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
Toast.makeText(context, "Wait We're sending mail", Toast.LENGTH_SHORT).show();
}
@Override
protected String doInBackground(String... strings) {
try {
GMailSender sender = new GMailSender("senderemailid@gmail.com",
"password");
sender.sendMail(strings[0], strings[1],
"senderemailid",strings[2]);
return "Email Successfully sent";
} catch (Exception e) {
Timber.e(e);
return "Email Send failed";
}
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
Toast.makeText(context, s, Toast.LENGTH_SHORT).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment