Android code for sending default mail without any button

You can use the following code to send a default email without any button click in Android:

public class MainActivity extends AppCompatActivity {

    private static final String EMAIL_ADDRESS = "[email protected]";
    private static final String EMAIL_PASSWORD = "your_password";
    private static final String EMAIL_SUBJECT = "Test Email";
    private static final String EMAIL_BODY = "This is a test email";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Create a new Intent to send an email
        Intent intent = new Intent(Intent.ACTION_SEND);

        // Set the type of email
        intent.setType("message/rfc822");

        // Set the default email address
        intent.putExtra(Intent.EXTRA_EMAIL, new String[]{EMAIL_ADDRESS});

        // Set the default email subject
        intent.putExtra(Intent.EXTRA_SUBJECT, EMAIL_SUBJECT);

        // Set the default email body
        intent.putExtra(Intent.EXTRA_TEXT, EMAIL_BODY);

        // Start the email intent
        startActivity(Intent.createChooser(intent, "Choose an Email client"));
    }
}

In this code, replace "[email protected]", "your_password", "Test Email", and "This is a test email" with your actual email address, password, subject, and body.

This code will start the default email client on your device and compose a new email with the specified subject and body. The email will be sent when the user clicks the "Send" button in the email client.

Note: This code will not actually send the email. It will only start the email client and compose a new email. The email will be sent when the user clicks the "Send" button in the email client.

Also, note that this code will not work if the user does not have an email client installed on their device.