I was trying an iOS app, and when I choose to send an email, the address was hidden, and instead it displayed a word (a name).
I'm trying to do the same in android, with no results until now.
Is it possible?
Try this:
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"Name Here <test#email.com>"});
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
intent.putExtra(android.content.Intent.EXTRA_TEXT, "");
startActivity(intent);
Note the format of the email address: Name Here <test#email.com>
Hope this helps!
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 a requirement that I need to send email from my application, I am using below code to send email...
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("Text/Plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{abc#gmail.com});
intent.putExtra(Intent.EXTRA_TEXT, "hello..");
startActivity(Intent.createChooser(intent, email_chooser_title));
The above code launching the email composer. But after I press on send button , I can see one toast message "Message Sending" , But my message not sent.
pl. help me to figure out where I did wrong in this, or let me know if any alternative to solve this.. thanks.
Intent i = new Intent(Intent.ACTION_SEND);
//i.setType("text/plain"); //use this line for testing in the emulator
i.setType("message/rfc822") ; // use from live device
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"test#gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT,"subject goes here");
i.putExtra(Intent.EXTRA_TEXT,"body goes here");
startActivity(Intent.createChooser(i, "Select email application."));
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.