How to pre-populate the sms body text via an html link

It turns out this is 100% possible, though a little hacky.

If you want it to work on Android you need to use this format:

<a href="https://stackoverflow.com/questions/6480462/sms:/* phone number here */?body=/* body text here */">Link</a>

If you want it to work on iOS, you need this:

<a href="https://stackoverflow.com/questions/6480462/sms:/* phone number here */;body=/* body text here */">Link</a>

Live demo here: http://bradorego.com/test/sms.html (note the “Phone and ?body” and “Phone and ;body” should autofill both the to: field and the body text. View the source for more info)

UPDATE:

Apparently iOS8 had to go and change things on us, so thanks to some of the other commenters/responders, there’s a new style for iOS:

<a href="https://stackoverflow.com/questions/6480462/sms:/* phone number here */&body=/* body text here */">Link</a>

(phone number is optional)

Leave a Comment