• 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: 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.

  • Follow-Ups:
    • Re: [Programmatically Filling In Body of E-Mail Message]
      • From: j o a r <email@hidden>
References: 
 >Re: [Programmatically Filling In Body of E-Mail Message] (From: j o a r <email@hidden>)

  • Prev by Date: Ask Before Quite,Best Way To Save INFO
  • Next by Date: Re: Geometric computation software
  • 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