package com.home;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class SendEmailActivity extends Activity implements OnClickListener {
private Button sendBtn;
private Button sendToManyBtn;
private Button sendAttachmentBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
sendBtn = (Button) findViewById(R.id.main_btn_send);
sendToManyBtn = (Button) findViewById(R.id.main_btn_send_many);
sendAttachmentBtn = (Button) findViewById(R.id.main_btn_send_attachment);
sendBtn.setOnClickListener(this);
sendToManyBtn.setOnClickListener(this);
sendAttachmentBtn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == sendBtn) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:+297890152@qq.com"));
intent.putExtra(Intent.EXTRA_SUBJECT, "這是單方傳送的郵件主題");
intent.putExtra(Intent.EXTRA_TEXT, "這是單方傳送的郵件內容");
startActivity(intent);
}
if (v == sendToManyBtn) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:297890152@qq.com"));
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {
"313766045@qq.com", "980324510@qq.com" });
// 抄送
intent.putExtra(Intent.EXTRA_CC,
new String[] { "981413230@qq.com" });
// 密送
intent.putExtra(Intent.EXTRA_BCC,
new String[] { "1316106487@qq.com" });
intent.putExtra(Intent.EXTRA_SUBJECT, "這是多方傳送的郵件主題");
intent.putExtra(Intent.EXTRA_TEXT, "這是多方傳送的郵件內容");
startActivity(intent);
}
if (v == sendAttachmentBtn) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL,
new String[] { "297890152@qq.com" });
intent.putExtra(Intent.EXTRA_SUBJECT, "這是包含附件的郵件主題");
intent.putExtra(Intent.EXTRA_TEXT, "這是包含附件的郵件內容");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(""));
intent.setType("text/plain");
startActivity(intent);
}
}
}