Well, im trying to make my app sending an email with infromation entered in the entry text elements, but when I try it in the phone it says "No application can perform this action. Here is my code. Thank you.
View boton = (Button) findViewById(R.id.enviar);
boton.setOnClickListener(this);
}
#Override
public void onClick(View v) {
if (v.getId()==findViewById(R.id.enviar).getId())
{
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String mailId= "villasantdesign#gmail.com";
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{mailId});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Consulta Técnica");
emailIntent.putExtra(Intent.EXTRA_TEXT, etlugar.getText()); etfecha.getText(); etcable.getText(); etqe.getText(); etantena.getText(); etampli.getText(); etmodulo.getText();}{
startActivity(Intent.createChooser(emailIntent, "Envío"));
}}}
You just need to configure an email account in your default Email application or in any other email clients like Gmail,so that It can redirect the user to that application and let him send the email.
Solution:
The below snippet works absolutely fine.
View boton = (Button) findViewById(R.id.enviar);
boton.setOnClickListener(this);
}
#Override
public void onClick(View v) {
if (v.getId()==findViewById(R.id.enviar).getId())
{
Intent emailIntent = new Intent(Intent.ACTION_SEND, Uri.fromParts("mailto","villasantdesign#gmail.com", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Consulta Técnica");
emailIntent.putExtra(Intent.EXTRA_TEXT, etlugar.getText());
startActivity(Intent.createChooser(emailIntent, "Envío"));
}}}
I hope it will be helpful !!
I think you have to install Email App to you phone, like Gmail, or Android can not find any App to receive that intent. And you should change Intent.ACTION_SEND to Intent.ACTION_SENDTO
Try setting up mime-type:
emailIntent.setType("text/plain");
& change android.content.Intent.ACTION_SENDTO instead of Intent.ACTION_SENDTO to get only the list of e-mail clients, with no facebook or other apps. Just the email clients.
You need to configure an email account in your default Email application.
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("plain/text");
email.putExtra(Intent.EXTRA_EMAIL,
new String[] { abc#gmail.com) });
email.putExtra(Intent.EXTRA_SUBJECT, "");
email.putExtra(Intent.EXTRA_TEXT,"");
startActivity(Intent.createChooser(email,
"Choose an Email client :"));
android.content.Intent.ACTION_SEND intent is the mail sending intent.Intent.createChooser(emailIntent, "Envío") will going to prompt you to select the mail sending application from the collection of configured sending applications like Gmail App. if no mail is configured in your device or simulator it will reply like no app can perform this action.
Related
I've integrated code to send an email from my app.i have search on that and found the solution which i have already integrated but it didn't work for me.
Basically, The code include the text and the subject but does not add the email address (on which we have to send email) in gmail.
Can any one help me?
protected void sendEmail (String strtwi){
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, "projectmyangel#hotmail.com");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Spread More Cheer!");
emailIntent.putExtra(Intent.EXTRA_TEXT, strtwi);
emailIntent.setType("message/rfc822");
startActivity(Intent.createChooser(emailIntent, "Email"));
}
change this line
emailIntent.putExtra(Intent.EXTRA_EMAIL, "projectmyangel#hotmail.com");
with
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"myEmail#gmail.com"});
if above didn't solve your issue try below:
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"myEmail#gmail.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(Intent.createChooser(intent, "Contact Me..."));
}
Android API does not supply the assignment of the email address (on which to send mail).
The intent is just a message that sent to the application you select in Intent.createChooser(emailIntent, "Email") and fill in the necessary columns refer to the information you have given.
Since the email address that the mail sent from differs from one user to another, it is better to choose them in the email application the user select rather than in your application.
I'm trying to make a app, that takes information of some sort, then i want it to email that information to my gmail. I have found working code but when i load it onto my phone and run it and got all the info loaded into the app,and click the email, from what i understand its suppose to filter apps(on my phone) that are capable to send the email but I'm not getting anything, even though i have the default Email app that comes on the phone and i have Gmail.
public void Done(View view) {
Intent email = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND
email.putExtra(Intent.EXTRA_EMAIL, "some#gmail.com");
email.putExtra(Intent.EXTRA_SUBJECT, "OverStock Changes");
email.putExtra(Intent.EXTRA_TEXT, printReport());
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Email"));
}
See answer for ACTION_SENDTO for sending an email
If you use ACTION_SENDTO, putExtra() does not work to add subject and
text to the intent. Use setData() and the Uri tool add subject and
text.
This example works for me:
// ACTION_SENDTO filters for email apps (discard bluetooth and others)
String uriText =
"mailto:youremail#gmail.com" +
"?subject=" + URLEncoder.encode("some subject text here") +
"&body=" + URLEncoder.encode("some text here");
Uri uri = Uri.parse(uriText);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
startActivity(Intent.createChooser(sendIntent, "Send email"));
Otherwise use ACTION_SEND as mentioned:
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"mail#mail.com","mail2#mail.com"});
intent.putExtra(Intent.EXTRA_SUBJECT,"subject");
intent.putExtra(Intent.EXTRA_TEXT, "mail content");
startActivity(Intent.createChooser(intent, "title of dialog"));
I have been working with Java and Xml for a few months now, and have learned a great deal thanks to everyones help on StackOverflow.
My question is about java programming for android in relation to the submit button.
Currently I am trying to figure out how to submit a value to an email address (behind the scenes)
Lets say we have a text field and a button; I want to take the value entered in the text field, and submit that to an email address onclick.
I am unable to find anything online that shows me how to do this.
Thank you in advance for reading through my post and I look forward to your suggestions.
This is a great example of how using Intents can come in great handy!
Android has a bunch of pre-defined Intents that do certain things within the system; you may have clicked on a picture before and a dialog popped up asking whether you would like to view it in your gallery or in a third-party app such as Astro. The viewing of an image has its own pre-determined intent.
Sending an email also has its own pre-determined intent: android.content.Intent.ACTION_SEND. You'll need to create an intent with that property and then attach extra information (ie. the address to send to, the subject/message body, etc.).
Example code:
// Data members
private Intent emailIntent;
private String feedback;
private EditText feedbackBox;
// Create the Intent, and give it the pre-defined value
// that the Android machine automatically associates with
// sending an email.
emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
// Put extra information into the Intent, including the email address
// that you wish to send to, and any subject (optional, of course).
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"your_email#whatever.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Insert subject here");
// Acquire feedback from an EditText and save it to a String.
feedback = feedbackBox.getText().toString();
// Put the message into the Intent as more extra information,
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, feedback);
// Start the Intent, which will launch the user's email
// app (make sure you save any necessary information in YOUR app
// in your onPause() method, as launching the email Intent will
// pause your app). This will create what I discussed above - a
// popup box that the user can use to determine which app they would like
// to use in order to send the email.
startActivity(Intent.createChooser(emailIntent, "Insert title for dialog box."));
I hoped this helped!!
Some sources you might like to check out:
http://developer.android.com/guide/topics/intents/intents-filters.html
http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, someEditText.getText());
startActivity(Intent.createChooser(emailIntent, "Send someone an email..."));
try this
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:Type email address here"));
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
It works good
String mail=mailid.getText().toString();
String msubject=subject.getText().toString();
String mbody=body.getText().toString();
Log.i("Send email", "");
String[] TO = {mail};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Static subject "+ msubject);
emailIntent.putExtra(Intent.EXTRA_TEXT, "Static body "+ mbody);
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
}
While starting the Gmail Composer com.google.android.gm.ComposeActivity in my App, I can use the intent parameter EXTRA_EMAIL set the to email adress. Is there anyway that can set the default from email address for ComposeActivity if I have more than one Gmail account on my device?
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
sendIntent.setType("plain/text");
sendIntent.putExtra(Intent.EXTRA_TEXT, body);
sendIntent.putExtra(Intent.EXTRA_EMAIL, cc#gmail.com);
sendIntent.putExtra(Intent.EXTRA_BCC, "bcc#gmail.com");
sendIntent.putExtra(Intent.EXTRA_CC, "cc#gmail.com");
sendIntent.putExtra(Intent.?????, "from#gmail.com"); //Can we set the from email?
sendIntent.setPackage("com.google.android.gm");
startActivity(sendIntent);
Thanks.
try this
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
and aEmailList is
String aEmailList[] = { "user#host.com","user2#host.com" };
Hope this will help you.
I've searched Google for this, but have only found similar examples--not exactly what I need. I simply need to start messaging (SMS) and email intents from my app with their "to" fields already populated. So I need to send a number with the sms intent and an email address with the email intent. Any help would be appreciated.
For the e-mail part :
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"foo#bar.com"});
emailIntent.setType("text/plain");
startActivity(Intent.createChooser(emailIntent, "Send a mail ..."));
from Only Email apps to resolve an Intent
String recepientEmail = ""; // either set to destination email or leave empty
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:" + recepientEmail));
startActivity(intent);
will filter out all non-email applications.