I am making an app in which i have to take feed back in edit text and send this feed back to a hard code email address. the user just enter his feed back and press button and then email will be sent to id. .. write now in my app instead of sending automatically an email ,user directed towards email page ..
kindly help me :)
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String[] recipients = new String[]{"email#example.com", "",};
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message");
emailIntent.setType("text/plain");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
}
});
Firstly use Mail.jar, activation.jar, Additional.jar file Upload in Your project
Use this Mail Class.. follow this Question there has provide answer how to send mail without intent in android
Send email in android using JavaMail API with smtp but without SSL
enjoy!
I belive this is solved HERE for Gmail.
I didn't tested THIS but might be quite good library for all hosts.
Don't forget to make it inside AsyncTask ;)
Related
I've implemented a class that can send a mail. However, you can only write a topic and the message and when you click on "Send" you've to choose which app (Outlook or Gmail) you want to send the mail with and then write your e-mail. However, I want to make it possible for the user to send a mail directly from the my app instead of using another app. So I want to make it possible for the user to write his/her e-mail/gmail and message and then send the message to my e-mail. So in other words in the fragment I want an EditText where the user writes his/her e-mail/gmail, another EditText where the user writes the message and a button to send. How can this be implemented?
This is what I have done in my app to send a mail:
private void sendemail(String message) {
String [] reciever = new String[]{"myemail#hotmail.com"};
String subject = ("Feedback/Question");
Intent mailIntent = new Intent(Intent.ACTION_SEND);
mailIntent.putExtra(Intent.EXTRA_EMAIL, reciever);
mailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
mailIntent.putExtra(Intent.EXTRA_TEXT, message);
mailIntent.setType("message/rfc822");
startActivity(Intent.createChooser(mailIntent, "Choose an application to send your mail with"));
}
Use this library -> Send email in background. It will send an email from your app without users interaction.
Cheers!
using java mailApi,you must have to authenticate gmail app using credential.
please check this link:
Email via Java MailAPI
other link to provide custom class to send mail programatically.
https://stackoverflow.com/a/4345084/1223291
I hope its useful to you.
Use this method....
public void sendEmail()
{
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"care#xyz.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "care Feedback");
intent.putExtra(Intent.EXTRA_TEXT, "");
startActivity(Intent.createChooser(intent, "Send Email"));
}
So I'm trying to launch a prepopulated email client with data. The content gets populated fine, however my problem is that when launching the intent, I wanted it to only show email clients to select from.
Instead, it shows Gmail, Adding to EverNote, Android Beam, Bluetooth, and some others.
I don't know if its an issue with lollipop that broke this functionality or not, as one of my managers sent me code that worked fine for him a few years ago.
My code is:
private void openEmailClient(){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{getResources().getString(R.string.contact_feedback_email_address)});
intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.contact_feedback_email_subject_android));
try{
startActivity(Intent.createChooser(intent,intentEmailString));
} catch(android.content.ActivityNotFoundException ex){
Log.e(EMAIL_FAIL_TAG, EMAIL_FAIL);
ex.printStackTrace();
}
}
when you will change your intent.setType like below you will get
intent.setType("text/plain");
Use
android.content.Intent.ACTION_SENDTO
(new Intent(Intent.ACTION_SENDTO);) to get only the list of e-mail clients, with no facebook or other apps. Just the email clients.
I wouldn't suggest you get directly to the email app. Let the user choose his favorite email app. Don't constrain him.
If you use ACTION_SENDTO, putExtra does not work to add subject and text to the intent. Use Uri to add the subject and body text.
We can use message/rfc822 instead of "text/plain" as the MIME type. However, that is not indicating "only offer email clients" -- it indicates "offer anything that supports message/rfc822 data". That could readily include some application that are not email clients.
message/rfc822 supports MIME Types of .mhtml, .mht, .mime
EDIT
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:someone#example.com"));
intent.putExtra("subject", "my subject");
intent.putExtra("body", "my message");
startActivity(intent);
its working ...
So I solved it. Not ideally but it works better than anything else I have tried.
I followed the google docs on doing it, which says to do this:
public void composeEmail(String[] addresses, String subject) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
and it now works.
This just finds a default app for handling mail. I'm not sure how it decides, but in my case it opened GMail. On a device without GMail installed, such as the Galaxy S5, it opened their mail client and prompted the user to set up email.
Doesn't give choice of app but it works
Try like this it working fine for me...
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:abc#gmail.com"));
intent.putExtra(Intent.EXTRA_SUBJECT, "Test App");
intent.putExtra(Intent.EXTRA_TEXT, "Email Body");
startActivity(intent);
Note: it only work if you have email address.
For more information please refer this link Android - Is there a foolproof way to only show possible EMAIL clients?
I have fragment. when click button,it send mail, but i don't know when mail send success, after i show dialog success.
my code send :
//Intent action send
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL,
new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT,
"bbbbb");
email.putExtra(Intent.EXTRA_TEXT,
"AAAAAAA"));
//need this to prompts email client only
email.setType("message/rfc822");
getActivity().startActivity(Intent.createChooser(email,
"Send mail..."));
i want show dialog when mail send success.
Please help me. thanks
It seems like there is no good solution for this.
The 'normal' way would be to use startActivityForResult() as you send your intent, but Intent.ACTION_SEND gives no output (documentation) so this doesn't work either. See this question.
The only way to do it for sure would be to make your own activity to send the email, and return a result from that.
I want to send email from my application using the default android email app. I have written a code for that as
Intent mailIntent = new Intent(android.content.Intent.ACTION_SEND);
mailIntent.setType("plain/text");
mailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { EMAIL });
mailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Invitation");
mailIntent.putExtra(android.content.Intent.EXTRA_TEXT,MAIL_MESSAGE);
startActivity(mailIntent);
But here it is opening the email application. I want to send the mail instead of starting any activity. Is there any ways to replace the startActivity and initiate the intent action?
Please help me.
Thanks in advance.
this link can be useful, have a look at another useful link or a code snippet from this link is attached below
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, newString[]{"yourmail#website.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mySubject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, myBodyText);
startActivity(Intent.createChooser(emailIntent, "Send mail));
Hope that helps...
yes you can done it by configuring the mail code on server side and from android call web service then server will send the mail
http://fahmirahman.wordpress.com/2011/04/21/connection-between-php-server-and-android-client-using-http-and-json/
I am creating an email intent and filling the message with a link that contains a hashmark:
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "http://en.wikipedia.org/wiki/Android_(operating_system)#Software_development");
Once I send this and reopen it on Android, the default mail client only makes the link to http://en.wikipedia.org/wiki/Android_(operating_system)
Is there a way to fix this problem?
This is a problem with Android's default mail. Links work great using the gmail app!
Try the following. I am unable to test my code because of problem in my IDE.
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("http://en.wikipedia.org/wiki/Android_(operating_system)#Software_development"));
Thanks
Deepak