Re: [NEWBIE] How to send an email with Cocoa?
Re: [NEWBIE] How to send an email with Cocoa?
- Subject: Re: [NEWBIE] How to send an email with Cocoa?
- From: Igor Couto <email@hidden>
- Date: Thu, 28 Oct 2004 09:38:00 +1000
On 27/10/2004, at 8:05 PM, Quinn wrote:
At 17:10 +1000 27/10/04, Igor Couto wrote:
I need to be able to send an email from inside my Cocoa application.
Rather than having to deal with network communications directly - and
reinvent the wheel - I thought it might be easier to simply create a
new email message,
The Cocoa-based Message framework will let you send messages directly.
So, you can avoid the user's email client if you want to.
Thank you very much for that hint!
How do I create a message with ATTACHMENTS?
1) Is there a way, from inside Cocoa, to create a new email message?
Is there a way to get the user's default email client to handle the
sending of the message?
The easiest way to do this is with a 'GURL' Apple event. The easiest
way to send such an event is via Launch Service's. The following code
does the trick, assuming that urlField is connected to an NSTextField
containing the URL.
(snip)...
An example of the extended mailto URL format is:
<mailto:email@hidden?
subject=Hello Cruel World&body=Share and Enjoy.>.
Once again, thank you very much for that hint. I did not want to use
'Launch Services', as it is part of the Carbon framework, and not
Cocoas. However, your hint put me on the right track. In Cocoa, the
NSWorkspace class has a method (-openURL:) that does basically the same
thing. Passing your 'mailto' url also launches the user's default
client, properly addressed - and with the right body.
I had not even tried using it, because according to Apple's
documentation, NSURL understands only URLs compliant with RFCs 1808,
1738 and 2732 (the ipV6 extension). Reading RFC 1738 - the one that
specified format for the 'mailto' schema - we see that all the
specification supports is the *simplest* form of the schema - ie,
specifying *only* the address, but no other parts of the message.
Because of that, I did not even bother to try! - silly me... :-P
So, I'm almost there. The only part of the task that I still cannot do
is: attach a file to the message! How can I do that?
Once again, many thanks for all the help!
--
Igor Couto
Sydney, Australia
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden