On 2010 Jan 28, at 07:34, Stephane Huaulme wrote:
> how can i do the equivalent of "new email with selection" service from a
> cocoa app programmatically?
As far as the "selection", if you mean from your app, you're going to have to
answer that for yourself. If you mean from another app, I don't know but
you'll probably find out when you learn the answer to the next question.
As far as creating a "service", if you mean something in the Services ▸ menu,
you're going to have to find and read the basic documentation on that yourself.
As far as creating an email message, use something like this:
+ (void)emailTo:(NSString*)address
subject:(NSString*)subject
body:(NSString*)body {
NSString* mailtoString = [NSString
stringWithFormat:@"mailto:%...@?subject=%@&body=%@",
(NSString*)[(NSString*)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)address, NULL, CFSTR("&"), kCFStringEncodingUTF8) autorelease],
(NSString*)[(NSString*)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)subject, NULL, CFSTR("&"), kCFStringEncodingUTF8) autorelease],
(NSString*)[(NSString*)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)body, NULL, CFSTR("&"), kCFStringEncodingUTF8) autorelease]] ;
// Create an email message in user's default email client
NSURL* mailtoURL = [NSURL URLWithString:mailtoString] ;
[[NSWorkspace sharedWorkspace] openURL:mailtoURL] ;
}
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]