The Cave

24 Nov

Send Email via mailto: on Mac OS X

Simple enough on Mac OS X:
NSString *content = @"subject=Hello&body=Peek-a-boo";
NSString *contentEscaped = [content stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *mailto = [NSString stringWithFormat:@"mailto:me@whatever.com?%@", contentEscaped];
NSURL *url = [NSURL URLWithString:mailto];
#if TARGET_OS_IPHONE
[[UIApplication sharedApplication] openURL:url];
#else
[[NSWorkspace sharedWorkspace] openURL:url];
#endif

Hard part was the Mac OS X call (NSWorkspace). There’s plenty of information on the web how to do this – for the iPhone. Needle in the haystack…

Thanks to Bill Dozier for the pointer to Apple’s tech note.

FacebookGoogle GmailGoogle BookmarksTechnorati FavoritesTwitterHotmailYahoo MailYahoo MessengerWordPressStumbleUponRedditEmailInstapaperGoogle+Share

Comments are closed.

© 2014 The Cave | Entries (RSS) and Comments (RSS)

GPS Reviews and news from GPS Gazettewordpress logo