2

I want to send email via my application and I am doing that by using intent and android system shows list of various component for this intent, but I do not want to send email with the help of these components, I want to send email via my application. Any help will be appreciated?

Sahil Mahajan Mj
  • 12,721
  • 8
  • 55
  • 101

2 Answers2

2

You can send e-mail in Android using the JavaMail API using Gmail authentication

Have a look at this post,

Sending Email in Android using JavaMail API without using the default/built-in app

Community
  • 1
  • 1
Sahil Mahajan Mj
  • 12,721
  • 8
  • 55
  • 101
0

Yes, it's possible. Hee you have good tutorial : http://thedevelopersinfo.wordpress.com/2009/10/22/email-sending-in-android/. I hope I helped.

Code snippet :

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

/**

* Class which shows how to send email

*

* @author FaYna Soft Labs

*/

public class Main extends Activity {

private Button clickBtn;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

clickBtn = (Button) findViewById(R.id.click);

clickBtn.setText("Send email");

clickBtn.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

String[] recipients = new String[]{"my@email.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();

}

});

}
TN888
  • 7,463
  • 9
  • 45
  • 83