Last active
January 2, 2022 13:41
-
-
Save RohanNavlakhe2/52082de0973abc87ff3cdc90d7220904 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("[email protected]", | |
"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