我想通过我的应用程序发送电子邮件,我正在通过使用intent和android系统显示这个意图的各种组件的列表,但我不想在这些组件的帮助下发送电子邮件,我想发送通过我的申请电邮。任何帮助将不胜感激?
答案 0 :(得分:2)
您可以使用Gmail身份验证
使用JavaMail API在Android中发送电子邮件看一下这篇文章,
Sending Email in Android using JavaMail API without using the default/built-in app
答案 1 :(得分:0)
是的,这是可能的。嘿,你有很好的教程:http://thedevelopersinfo.wordpress.com/2009/10/22/email-sending-in-android/。我希望我能帮忙。
代码段:
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();
}
});
}