Last active
January 11, 2016 14:00
-
-
Save Khanashima/76b97badcf83d643f0e8 to your computer and use it in GitHub Desktop.
Androidのインテントを使った複数宛先のメール送信 ref: http://qiita.com/kiimiiis/items/53a484374e40ceff8956
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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