Skip to content

Instantly share code, notes, and snippets.

@jack-webb
Created June 1, 2023 10:45
Show Gist options
  • Save jack-webb/42842dc0eff63bf8b6440e9a9778c976 to your computer and use it in GitHub Desktop.
Save jack-webb/42842dc0eff63bf8b6440e9a9778c976 to your computer and use it in GitHub Desktop.
An intent for sending plain text in an email
val message = "Hello world!"
val emailSelectorIntent = Intent(Intent.ACTION_SENDTO).apply {
  setData(Uri.parse("mailto:"))
}
val targetIntent = Intent(Intent.ACTION_SEND).apply {
  putExtra(Intent.EXTRA_TEXT, message)
  type = "text/plain"
}
targetIntent.selector = emailSelectorIntent
startActivity(targetIntent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment