Android 使用 Gmail 来发送邮件

1.[代码]SendMail.java

package org.apache.android.mail;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SendMail extends Activity {
/**
* Called with the activity is first created.
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
final Button send = (Button) this.findViewById(R.id.send);
final EditText userid = (EditText) this.findViewById(R.id.userid);
final EditText password = (EditText) this.findViewById(R.id.password);
final EditText from = (EditText) this.findViewById(R.id.from);
final EditText to = (EditText) this.findViewById(R.id.to);
final EditText subject = (EditText) this.findViewById(R.id.subject);
final EditText body = (EditText) this.findViewById(R.id.body);
send.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
GMailSender sender = new GMailSender(userid.getText().toString(),
password.getText().toString());
try {
sender.sendMail(subject.getText().toString(),
body.getText().toString(),
from.getText().toString(),
to.getText().toString());
} catch (Exception e) {
Log.e("SendMail", e.getMessage(), e);
}
}
});
}
}

更多相关文章

  1. Android中Binder类代码(android-5.0.2)
  2. 开发中常用到的几处代码设置
  3. Android代码实现APK文件的安装与卸载
  4. Android 发送短信 源代码
  5. android 常用代码备份
  6. [Android] 代码实现按钮/图片自旋转(中心旋转)
  7. android 的C++代码都加 namespace android
  8. Android代码混淆一定要Export Android Application,否则不起效
  9. Android的Location功能代码

随机推荐

  1. Android(安卓)基本控件及表单三大控件,事
  2. 详解 Android(安卓)的 Activity 组件
  3. android:shape的使用
  4. 关于android和java环境和编译的一些基本
  5. Android之Adapter用法总结
  6. Android(安卓)分析 Android(安卓)应用结
  7. 面向UDP的Android——PC双向通信(一):实现An
  8. Android攻城狮面试指南
  9. Pro Android(安卓)4 第三章 理解Android
  10. 试玩Android(一)