Skip to content

Instantly share code, notes, and snippets.

@Khanashima
Last active January 11, 2016 14:00
Show Gist options
  • Save Khanashima/76b97badcf83d643f0e8 to your computer and use it in GitHub Desktop.
Save Khanashima/76b97badcf83d643f0e8 to your computer and use it in GitHub Desktop.
Androidのインテントを使った複数宛先のメール送信 ref: http://qiita.com/kiimiiis/items/53a484374e40ceff8956
List<String> emails = new ArrayList<>();
StringBuilder mailTo = new StringBuilder();
mailTo.append("mailto:");
for (String email : emails) {
if(android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
//正しいメアドの時だけ追加する
mailTo.append(email);
mailTo.append(",");
}
}
//メール送信起動
// インテントのインスタンス生成
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SENDTO);
//宛先の設定
intent.setData(Uri.parse(mailTo.toString()));
//件名の設定
intent.putExtra(Intent.EXTRA_SUBJECT, "件名");
//本文の設定
intent.putExtra(Intent.EXTRA_TEXT, "本文");
// メール起動
startActivity(intent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment