I'm looking to call the Gmail app with a preconfigured subject and the body contains HTML using the following:
let gmail = URL(string:"googlegmail:///co?subject=Subject&body=<body><H1>testing</H1></body>")
UIApplication.shared.openURL(gmail!)
This will crash the app, I then resort to:
var messageEncoded1 = "<body><H1>testing</H1></body>".addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)
let gmail = URL(string:"googlegmail:///co?subject=Subject&body="+messageEncoded1!")
UIApplication.shared.openURL(gmail!)
And this will create a URL and open Gmail, however, body of the email shows: <body><H1>testing</H1></body>
and not the work testing
like so:
So the question is, is there a way to specify that the body holds HTML so that Gmail can render it as HTML?
No, for now, Gmail doesn't render it as HTML. Moreover, mailto
standard RFC2368 itself doesn't obligate to render tags in body
property:
The special hname "body" indicates that the associated hvalue is the body of the message. The "body" hname should contain the content for the first text/plain body part of the message. The mailto URL is primarily intended for generation of short text messages that are actually the content of automatic processing (such as "subscribe" messages for mailing lists), not general MIME bodies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With