• 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: [Programmatically Filling In Body of E-Mail Message]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Programmatically Filling In Body of E-Mail Message]


  • Subject: Re: [Programmatically Filling In Body of E-Mail Message]
  • From: j o a r <email@hidden>
  • Date: Tue, 27 May 2003 21:32:27 +0200

I use a category on NSString for that purpose:

@implementation NSString (MyAdditions)

- (NSString *) stringByAddingPercentEscapes
{
NSString *escapedString =
(NSString *)CFURLCreateStringByAddingPercentEscapes (NULL, (CFStringRef)self, NULL, NULL, NULL);
return [escapedString autorelease];
}

@end

After adding this category you can take any string, and turn it into an escaped string suitable to be used for the URL methods, etc. Something like this:

NSString *escapedString = [anyString stringByAddingPercentEscapes];

Given that you have two strings: the subject for the message and the body for the message - this is how you'd create a message in the default email client:

NSString *urlString = [NSString stringWithFormat: @"mailto:email@hidden?subject=%@&body=%@";, localizedSubject, localizedBody];
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: [urlString stringByAddingPercentEscapes]]];

j o a r

On Tuesday, May 27, 2003, at 20:44 Europe/Stockholm, Erik J. Barzeski wrote:

You are correct. My message was somewhat hastily written. I should have just
provided the email address and not the [NSWorkspace openURL] thing, which is
not really going to work.

:)

Is CFURLCreateStringByAddingPercentEscapes() of no help?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: [Programmatically Filling In Body of E-Mail Message]
      • From: Rolf <email@hidden>
References: 
 >Re: [Programmatically Filling In Body of E-Mail Message] (From: "Erik J. Barzeski" <email@hidden>)

  • Prev by Date: Re: Custom header for NSTableView
  • Next by Date: Ask Before Quite,Best Way To Save INFO
  • Previous by thread: Re: [Programmatically Filling In Body of E-Mail Message]
  • Next by thread: Re: [Programmatically Filling In Body of E-Mail Message]
  • Index(es):
    • Date
    • Thread