Sending an email using intent

good day guys

i have created an android app with a button,when you click that button it sends an sms to some phone numbers, now i want the app to also send an email.i used this code

Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_EMAIL, new String{“”});
i.putExtra(Intent.EXTRA_SUBJECT, “subject of email”);
i.putExtra(Intent.EXTRA_TEXT, “I need help urgent… I am at this location:”
+ locationMessage);
“Email sent.”, Toast.LENGTH_LONG).show();

the problem is it opens the email client instead of outomatically sending the email, how do get it to send the email outomatically when the button is clicked


Yes, this is the sharing intent that you would use to get a list of apps that support email. If you want to not use that functionality, the best option would be to create a webservice endpoint you could hit with the data, which then handles the sending of the email. Instead of trying to do it from the client


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.