Posted on September 14, 2008 at 12:19am EDT. More.

iPhone openURL: limit

I am currently working on an iPhone app which manages data and allows it to be exported over email.  An iPhone app cannot easily send an email directly from within an application, but it can ask the system to open a mailto: URL with a subject and body provided as parameters.  Unfortunately, the documentation does not indicate whether there is a limit to the size of the URL.

To find out, I wrote a test application which creates a mailto: URL of a specified length and then asks the system to open it.  On iPhone OS 2.0.2, I was able to successfully create an URL over 1 million bytes long and view the resulting message in the iPhone Mail app.

I tried some larger numbers, and ran into problems in both my test app or, if the URL opened, in the Mail app.  I didn’t try too rigorously to find a precise limit, because 1 MB is more than large enough for my purposes.  It appears, however, that there is no fixed limit on URL length, and the system will try to honor whatever memory will allow it to.