本文介绍了如何从Android应用程序发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经试过这至今
register.setOnClickListener(新OnClickListener()
{
@覆盖
公共无效的onClick(视图v)
{
用户名= username.getText()的toString();
。电子邮件= email.getText()的toString();
的System.out.println(点击注册按钮);
的System.out.println(用户名是:+用户名);
的System.out.println(电子邮件ID是:+电子邮件);
意图I =新的意图(Intent.ACTION_SEND);
i.setType(text / plain的);
i.putExtra(Intent.EXTRA_EMAIL,电子邮件);
i.putExtra(Intent.EXTRA_EMAIL,电子邮件);
i.putExtra(Intent.EXTRA_SUBJECT,你注册了印度航展);
i.putExtra(Intent.EXTRA_TEXT,让打印出此电子邮件,而来到会场);
尝试 {
startActivity(Intent.createChooser(我,发送邮件...));
}赶上(android.content.ActivityNotFoundException前){
ex.printStackTrace();
}
}
});
解决方案
进口android.app.Activity;
进口android.content.Intent;
进口android.os.Bundle;
进口android.view.View;
进口android.view.View.OnClickListener;
进口android.widget.Button;
/ **
*类展示了如何发送电子邮件
*
* @author Fayna酒店软实验室
* /
公共类主要扩展活动{
私人按钮clickBtn;
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
clickBtn =(按钮)findViewById(R.id.click);
clickBtn.setText(发送电子邮件);
clickBtn.setOnClickListener(新OnClickListener(){
@覆盖
公共无效的onClick(视图v){
意图emailIntent =新的意图(android.content.Intent.ACTION_SEND);
的String []收件人=新的String [] {[email protected],,};
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,收件人);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,测试);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,这是电子邮件的信息);
emailIntent.setType(text / plain的);
startActivity(Intent.createChooser(emailIntent,发送邮件...));
完();
}
});
}
}
I have tried this till now
register.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Username = username.getText().toString();
Email = email.getText().toString();
System.out.println("clicked register Button");
System.out.println(" User name is :" + Username );
System.out.println(" Email Id is :" + Email);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , Email);
i.putExtra(Intent.EXTRA_EMAIL , Email);
i.putExtra(Intent.EXTRA_SUBJECT, "You are registered for Aero india");
i.putExtra(Intent.EXTRA_TEXT , "Get the print out of this email while coming to the venue");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
ex.printStackTrace();
}
}
});
解决方案
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[]{"[email protected]", "",};
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();
}
});
}
}
这篇关于如何从Android应用程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!