|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Cocoa/Objective-C: How to get a users default email app?
Hi,
After doing some searching around, I'm not finding out how to detect which email client is the user's default. Any guidance in this? Thanks in advance, Mark |
|
|
|
0
|
|
|
#2 |
|
Use LSGetApplicationForURL():
Code:
NSURL *mailtoURL = [NSURL URLWithString:@"mailto:"]; CFURLRef emailURL = NULL; LSGetApplicationForURL((CFURLRef)mailtoURL, kLSRolesAll, NULL, &emailURL); NSLog(@"email url: %@", [(NSURL *)emailURL autorelease]); |
|
|
|
0
|
|
|
#3 |
|
Cool -- Thanks!
I just gave your code snippet a try and it returned: email url: file://localhost/Applications/Thunderbird.app/ . . . which is spot on. So, next I have to look into how to use this to open a new email message and hand it an attachment file. -- Mark |
|
|
|
0
|
|
|
#4 |
|
Hmmm. I'm beginning to wonder if this can be done. This code:
Code:
CFURLRef mtURL = CFURLCreateWithString(kCFAllocatorDefault,CFSTR("mailto:someone@email.com"), NULL);
LSOpenCFURLRef(mtURL,nil);
The other possibility is to use the information returned by "LSGetApplicationForURL" to get a path to the app, craft specific command line arguments for each email client, then use NSTask to launch it. Seems like this could be involve lot of work. -- Mark |
|
|
|
0
|
|
|
#5 |
|
Adding an attachment in Mail via AppleScript (Scripting Bridge) wouldn't be that hard I imagine. Do you have to do this in the user's client? Maybe you could provide your own server to do the emailing instead.
|
|
|
|
0
|
|
|
#6 |
|
Maybe some kind of AppleScript is my answer. I don't know a thing about AppleScript but I'll look into it.
This is strictly a local application. It's for document scanning and I want it to be able to send the scanned doc directly into email as well as into folders, etc. One thing that indicates that this is not an easy proposition is my comparison of apps on the Mac and Windows platforms. The "ScanGear Toolbox" that my old Canon N670U uses is available for both platforms and while the Windows version lists all of my installed email clients for its 'scan to email' function, the Mac version does not. Also, one of my customers uses a Fujitsu scanner and, while it's "ScanSnap" software does offer an email option, it apparently will only work with Mac Mail (and, of course, he uses something else). -- Mark |
|
|
|
0
|
|
|
#7 | |
|
Quote:
|
||
|
|
0
|
|
|
#8 |
|
NSWorkspace supports this
I personally find this a bit easier than using LaunchServices, and it plays nicely with ARC since there's no casting of CF types.
Code:
NSURL *emailAppURL = [[NSWorkspace sharedWorkspace] URLForApplicationToOpenURL:[NSURL URLWithString:@"mailto:"]]; |
|
|
|
0
|
|
|
#9 | |
|
Version of default mail client?
Quote:
How should i proceed? Thanks |
||
|
|
0
|
|
|
#10 | |
|
Quote:
Code:
NSDictionary *nsAppInfo; NSBundle *nsAppBundle; NSString *nsAppPath; NSWorkspace *nsSharedWorkspace = [NSWorkspace sharedWorkspace]; nsAppPath = [nsSharedWorkspace fullPathForApplication:appName]; nsAppBundle = [NSBundle bundleWithPath: nsAppPath]; nsAppInfo = [nsAppBundle infoDictionary]; NSLog(@"%@", [nsAppInfo objectForKey:@"CFBundleShortVersionString"]); NSLog(@"%@", [nsAppInfo objectForKey:@"CFBundleVersion"]); Thanks. Last edited by dejo; Mar 15, 2013 at 12:29 PM. Reason: Please use [code] tags. |
||
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| TUTORIAL: How to get PCSX2 to run on Mac(without Bootcamp) | Mirrors | Mac Applications and Mac App Store | 21 | Mar 14, 2013 03:34 PM |
| Does anybody know how to get TweetTask? | xmelissaxmayhem | Jailbreaks and iOS Hacks | 3 | Jul 3, 2011 01:21 AM |
| How to make Calvetica my default Calendar app especially for event notifications? | EvilEvil | iPhone Tips, Help and Troubleshooting | 0 | Feb 14, 2011 07:20 AM |
| How to get path of default image folder of iPhone. | rahul4tcs | iPhone/iPad Programming | 0 | Jun 3, 2009 12:21 AM |
| How to set iChat as default IM app | bajiaomao | Mac Applications and Mac App Store | 0 | Aug 7, 2007 07:08 PM |
All times are GMT -5. The time now is 06:09 AM.







Linear Mode

