Re: [Programmatically Filling In Body of E-Mail Message]
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.