LoginSignup
3
3

More than 5 years have passed since last update.

Androidのインテントを使った複数宛先のメール送信

Last updated at Posted at 2016-01-11

Androidのインテントを使った複数宛先のメール送信

方法

mailto:メアド1,メアド2,...とカンマつなぎで行う

コード

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);

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3