Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Readymade solution to parse mailto URLs in Cocoa?

I have a UIWebView in an iPhone app and want to intercept structured mailto-URLs like mailto:[email protected]?subject=foo&body=bar in order to display a MFMailComposeViewController inside the app instead of handing over the URL to Mail.app.

Now it would be great if all properties of MFMailComposeViewController would be automatically set according to the mailto URL. Unfortunately, MFMailComposeViewController does not accept a mailto URL but requires to set the individual properties.

NSURL apparently is not of great help either. Are you aware any existing code so that I don't have to write the parser code? ;)

like image 352
Ortwin Gentz Avatar asked Dec 06 '22 00:12

Ortwin Gentz


2 Answers

Wrote my own solution: https://gist.github.com/667952 It's a bit ugly and probably not 100% foolproof in terms of RFC support, but as long as the syntax of the mailto URLs is under your own control, it works fine.

like image 56
Ortwin Gentz Avatar answered Dec 18 '22 16:12

Ortwin Gentz


Ortwin, thanks for your code. I forked it to add a check on the canSendMail method and to add it as a category of MFMailComposeViewController. Please, find it here: https://gist.github.com/788075

like image 27
MonsieurDart Avatar answered Dec 18 '22 16:12

MonsieurDart