Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9134031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:35:23+00:00 2026-06-17T08:35:23+00:00

I had recently asked a question regarding the following code: Sending Email in Android

  • 0

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 this in regards to a network error, as per a previous question:

Need Help Debugging Email Code

My question is, how would I implement an AsyncTask in order to successfully send an email with this Android code? Every tutorial that I see informs me that I should do

extend AsyncTask {

However, GMailSender.java already has this defined as:

public class GMailSender extends javax.mail.Authenticator

Would anyone be able to help me? Thanks!

NOTE:

Please don’t be like the idiot who had -1ed this question and posted the exact answer as was given in Sending Email in Android using JavaMail API without using the default/built-in app. I am unable to use that exact coding, due to the fact that it is no longer possible to run a network operation on the main thread of an Android application. I am looking for a way to use AsyncTask in order to run the operation in the background. What I am unable to find out is how to do

extend AsyncTask {

without touching

public class GMailSender extends javax.mail.Authenticator
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:35:24+00:00Added an answer on June 17, 2026 at 8:35 am

    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();
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently asked a question (and had it answered) here: jQuery Load JSON I
Recently I asked a question on SO that had mentioned the possible use of
I've recently asked and had answered this question and it's stopped the issue of
I recently asked/accepted an answer to a question I had earlier: How can I
Ok I had asked a question recently based on this. But I need to
I had recently asked a related question In C# how do I have a
Recently i had an interview in which the question was asked as How would
I recently asked a question regarding how to save large python objects to file.
I recently asked a question about counting the number of times an element had
Recently I had a question on the interview - I was asked to compare

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.