Android 使用 Gmail 来发送邮件

SendMail.java
01package org.apache.android.mail;
02
03import android.app.Activity;
04import android.os.Bundle;
05import android.util.Log;
06import android.view.View;
07import android.widget.Button;
08import android.widget.EditText;
09
10public class SendMail extends Activity {
11/**
12* Called with the activity is first created.
13*/
14@Override
15public void onCreate(Bundle icicle) {
16super.onCreate(icicle);
17setContentView(R.layout.main);
18final Button send = (Button) this.findViewById(R.id.send);
19final EditText userid = (EditText) this.findViewById(R.id.userid);
20final EditText password = (EditText) this.findViewById(R.id.password);
21final EditText from = (EditText) this.findViewById(R.id.from);
22final EditText to = (EditText) this.findViewById(R.id.to);
23final EditText subject = (EditText) this.findViewById(R.id.subject);
24final EditText body = (EditText) this.findViewById(R.id.body);
25send.setOnClickListener(new View.OnClickListener() {
26public void onClick(View view) {
27GMailSender sender = new GMailSender(userid.getText().toString(),
28password.getText().toString());
29try {
30sender.sendMail(subject.getText().toString(),
31body.getText().toString(),
32from.getText().toString(),
33to.getText().toString());
34} catch (Exception e) {
35Log.e("SendMail", e.getMessage(), e);
36}
37}
38});
39}
40}

转载于:https://www.cnblogs.com/tuncaysanli/archive/2012/04/24/2469088.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值