今天的比較簡單 想要發送信件的話 利用intent即可
private fun sendEmail() {
Log.i("Send email", "")
val TO = arrayOf("kllilee21@gmail.com")
val CC = arrayOf("kllilee21@gmail.com")
val emailIntent = Intent(Intent.ACTION_SEND)
emailIntent.data = Uri.parse("mailto:")
emailIntent.type = "text/plain"
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO)
emailIntent.putExtra(Intent.EXTRA_CC, CC)
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject")
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message goes here")
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."))
finish()
Log.i("Finished sending email", "")
} catch (ex: android.content.ActivityNotFoundException) {
Toast.makeText(this@MainActivity,
"There is no email client installed.", Toast.LENGTH_SHORT).show()
}
}
這樣的話就可以利用系統叫出內建的email發送系統
明天來看看有沒有可以不利用系統內建的來發送
今天先到這裡