2

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.

Anu
  • 1,884
  • 14
  • 30
  • 1
    Exact duplicate of this http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-android-a – asktomsk Mar 21 '12 at 13:14

2 Answers2

2

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...

Azat-777
  • 95
  • 1
  • 10
Amit
  • 13,134
  • 17
  • 77
  • 148
0

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/

vipin
  • 2,851
  • 4
  • 18
  • 32