• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how can i do the equivalent of "new email with selection" service?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >how can i do the equivalent of "new email with selection" service? (From: Stephane Huaulme <email@hidden>)

  • Prev by Date: Re: NSSlider
  • Next by Date: Re: Which CA Layer am I dragging over?
  • Previous by thread: how can i do the equivalent of "new email with selection" service?
  • Next by thread: NSSlider
  • Index(es):
    • Date
    • Thread