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: Rolf <email@hidden>
- Date: Tue, 27 May 2003 22:20:03 +0200
Thanks :-)
BTW: Its also possible to use NSMailDelivery. Unfortunately NSMailDelivery does not seem to be documented anywhere. The following transmits a simple mail:
BOOL result;
NSString *message = @"This is a message";
NSString *recipient = @"email@hidden";
NSString *subject = @"Hi";
result = [NSMailDelivery deliverMessage:message subject:subject to:recipient];
if (result == NO) {
NSRunInformationalAlertPanel(@"Mail",@"Sending mail failed. Make sure that a mail account been setup.",@"Ok",@"",@"");
}
NSMailDelivery also supports file attachemnts, but I haven't got that working.
/Rolf
27.05.2003 21:32:27, skrev j o a r <email@hidden>:
>
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.