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/
Related
I'm currently trying to create an app that will take a picture and then attach that picture to an email and send the email.
what i m trying to say
step
1. add recipient Email Address.
2. add Subject.
3. add Some Text.
and Last And Main
4. Attach image from camera and sent that Mail.
I want to send mail from my own application only?? without using any inbuilt Gmail app?
Try below code
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Myimage.jpeg"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
UPDATE
Try this link, it will help you
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"));
}
How can I create a simple program that it can send a text to a gmail address?
I want to create a simple program that it have a EditText and when I write some text in the EditText and I click on the Button, as the result the text be sent to a gmail address, for example to the example#gmail.com. I know how to create a EditText class but I do not know the operation post to the gmail. Thank you.
In Android, you can use Intent.ACTION_SEND to call an existing email client to send an Email.
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"put_your_mail#gmail.com"});
email.putExtra(Intent.EXTRA_SUBJECT, "subject");
email.putExtra(Intent.EXTRA_TEXT, "message");
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
For more details you visit How to send Email in Android and
http://code.tutsplus.com/tutorials/quick-tip-enabling-users-to-send-email-from-your-android-applications-the-easy-way--mobile-1686
Standard way to do this is using the ACTION_SEND intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress#emailaddress.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");
startActivity(Intent.createChooser(intent, "Send Email"));
If you want to send the mail in background without opening another app check this answer https://stackoverflow.com/a/2033124/2761055
Here, you have information how to do that in background with PHP file on your server.
But in my opinion, this method is deprecated.
Look also here. This code will start new intent with email.
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 ;)
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