views:

185

answers:

2

Hi,

I have an NSTextView with text & images in it, which is supposed to send both in an e-mail.I know that the message.framework is deprecated,so I came up with the idea to send it via NSTask, since mail is integrated.I came up with the code below, however in the log I get this:

* -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: _NSTaskInputFileHandle)

This is the code I am using:

NSError *error;
    if([textView writeRTFDToFile:@"/Library/Application Support/log.rtfd" atomically:NO])
    {
        NSArray *args = [NSArray arrayWithObjects:@"-s", [subject stringValue], [sendto stringValue], nil];

        NSTask *task = [[[NSTask alloc] init] autorelease];
        [task setLaunchPath:@"/usr/bin/mailx"];
        [task setArguments:args];
        [task setStandardInput:[NSFileHandle fileHandleForReadingAtPath:@"/Library/Application Support/log.rtfd"]];
        [task launch];
        [task waitUntilExit];

Can someone tell me what I am doing wrong?

A: 

You can also try the Scripting Bridge. See Apple's SBSendEmail example.

Diederik Hoogenboom
A: 

Check my answer in: How can I send a HTML email from Cocoa?

catlan