Re: how can i do the equivalent of "new email with selection" service?
Re: how can i do the equivalent of "new email with selection" service?
- Subject: Re: how can i do the equivalent of "new email with selection" service?
- From: Jerry Krinock <email@hidden>
- Date: Thu, 28 Jan 2010 10:38:52 -0800
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@hidden)
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:
This email sent to email@hidden