Intent.EXTRA_EMAIL not populating the To field

前端 未结 6 1669
有刺的猬
有刺的猬 2021-02-03 16:35

I am trying to use an intent to send an email from my application but the To field of the email will not populate. If I add code to fill in the subject or text, they work fine.

6条回答
  •  滥情空心
    2021-02-03 17:13

    This is what works for me:

    val email = "recipient@email.com"
    val intent = Intent(Intent.ACTION_SENDTO)
    intent.data = Uri.parse("mailto:$email")
    intent.putExtra(Intent.EXTRA_SUBJECT,"My Subject")
    startActivity(intent)
    

提交回复
热议问题