• 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: [Newbie] Ampersands in NSURL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Newbie] Ampersands in NSURL


  • Subject: Re: [Newbie] Ampersands in NSURL
  • From: Jeremy Dronfield <email@hidden>
  • Date: Sun, 22 Sep 2002 13:25:19 +0100

On Sunday, September 22, 2002, at 01:58 am, Joseph Feld wrote:

I'm sure this is a stupid question, but I can't find an answer anywhere else so here goes: I'm trying to do a "mailto:"; URL from my application and I can't get NSURL to accept an ampersand in the addr-specs, even though RFC 2368 and RFC 822 both say that it's allowed. When I take it out and just use a single header in the URL the NSWorkspace fires my mail app just fine. I've tried using the & hex value encoding in the URL, but NSURL still returns nil. Does anyone have any ideas on how I would format a mailto: URL to accept multiple headers?

Difficult to answer, since you don't specify what headers you want. You can add a Cc, subject and some message text like so:

NSURL *url=[NSURL URLWithString:@"mailto:email@hidden?cc=email@hidden&subject=
My Subject Text&body=Message text"];
[[NSWorkspace sharedWorkspace] openURL:url];

... which gives the following headers:

To: email@hidden
Cc: email@hidden
Subject: My Subject Text

Message text

If all you want is to get ampersands into your headers, & works just fine OMM, like so:

NSURL *url=[NSURL URLWithString:@"mailto:email@hidden?cc=email@hidden&subject=
My Subject & Subject2Text&body=Message text"];
[[NSWorkspace sharedWorkspace] openURL:url];

... which produces headers:

To: email@hidden
Cc: email@hidden
Subject: My Subject & Subject2Text

Message text

-Jeremy

========================================
email@hidden // email@hidden
The Alchemy Pages:
- fractious fiction at http://freespace.virgin.net/jeremy.dronfield
========================================
_______________________________________________
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: [Newbie] Ampersands in NSURL
      • From: Joseph Feld <email@hidden>
References: 
 >[Newbie] Ampersands in NSURL (From: Joseph Feld <email@hidden>)

  • Prev by Date: Re: NSRecentDocumentRecords
  • Next by Date: Re: NSRecentDocumentRecords
  • Previous by thread: [Newbie] Ampersands in NSURL
  • Next by thread: Re: [Newbie] Ampersands in NSURL
  • Index(es):
    • Date
    • Thread