I am trying to send html code (round 500rows / frontend) as part of a string with the given code below. But when i select email app, i see only tags and jacascript/styles etc in the beginning of the email, and at the bottom i see the Texts. I think it may be a problem with the styles or i am missing something.

 val intent = Intent(Intent.ACTION_SEND)
    intent.type = "text/html"
    intent.putExtra(Intent.EXTRA_SUBJECT, "Template")
    intent.putExtra(Intent.EXTRA_TEXT,spannable)
    if (Build.VERSION.SDK_INT >= 24) {
        fromHtml(spannable.toString(), TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)
    } else {
        fromHtml(spannable.toString()) // or for older api
    }
    startActivity(Intent.createChooser(intent, "Send Email"))

Would like some help, thanks in advance.

1 Answers

0
CommonsWare On

You cannot send arbitrary HTML via ACTION_SEND through an email client. You will be limited by the capabilities of the email composer UI of the user's chosen email client. In particular, such a composer is unlikely to be able to handle any HTML that cannot be represented as CharacterStyle objects in an EditText. So, if you are using JavaScript, CSS, <iframe>, tables, and similar things, those are very unlikely to work for any given email client.