发送Email的简短代码

public class EmailListener implements OnClickListener{

 

@Override

public void onClick(DialogInterface dialog, int which) {

//新建一个E-mail 的Intent

Intent EmailIntent = new Intent(Intent.ACTION_SEND);

 

//设置E-mail标题

String subject = "关于 aLibro";

EmailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);

 

//设置Email的内容

String body = "关于 aLibro 的开发";

EmailIntent.putExtra(Intent.EXTRA_TEXT, body);

 

//设置要发送到的Email地址

String[] Email_to = new String[]{"to1@example.com","to2@example.com"};

EmailIntent.putExtra(Intent.EXTRA_EMAIL, Email_to);

 

//设置抄送的Email地址

String[] Email_cc = new String[]{"cc1@example.com","cc2@example.com"};

EmailIntent.putExtra(Intent.EXTRA_CC, Email_cc);

 

//设置密送的Email地址

String[] Email_bcc = new String[]{"bcc1@example.com","bcc2@example.com"};

EmailIntent.putExtra(Intent.EXTRA_BCC, Email_bcc);

 

//如果是一般的Email,应该是纯文字的形态

EmailIntent.setType("text/plain");

 

//让用户自行决定要传送的E-mail客户端

startActivity(Intent.createChooser(EmailIntent, "E-mail chooser"));

}

 

}

 

权限设置:

<uses-permission android:name="android.permission.SEND_SMS"/>

posted @ 2012-04-19 13:39  幻星宇  阅读(307)  评论(0编辑  收藏  举报