Displaying NSString in default mail client

Discussion in 'Mac Programming' started by zed2, May 10, 2010.

  1. zed2 macrumors 6502a

    Joined:
    Jul 17, 2004
    Location:
    Bucks
    #1
    Hi all,

    I'm writing an application which is pulling archived e-mails from a server..Once I've pulled the RAW message I want to display it.

    Can anyone suggest away to push the NSString of the message over to the default mail client and have it display it in a "viewer" window?

    Cheers
     
  2. MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #2
    You could (Assuming you're using Mac OSX) use a NSTextField to display the contents. As far as I know you won't be able to launch it with a Email program.
     
  3. zed2 thread starter macrumors 6502a

    Joined:
    Jul 17, 2004
    Location:
    Bucks
    #3
    Yeah, however rendering a MIME message in NSTextField is just not good..

    I have however found a solution:

    [_messageBody writeToFile:_fileName atomically:TRUE encoding:NSUTF8StringEncoding error:NULL];
    [[NSWorkspace sharedWorkspace] openFile:_fileName];

    Basically write the string to a temp file and then ask the file system to open the file in the default viewer... saving the file with a ".eml" extension means mail! :p
     
  4. MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #4
    That may work for Apple Mail but may not for other like Thunderbird etc. It might of changed, but I remember Thunderbird using some random XML encumbered format.
     

Share This Page