Sending mail with HTML

Discussion in 'Mac Programming' started by paos, Sep 15, 2009.

  1. paos macrumors newbie

    Joined:
    Aug 13, 2009
    #1
    I want to send a mail with HTML in it, I'm using somethiong like this:

    Code:
    NSString *mailRecipeData;
    mailRecipeData = [NSString stringWithFormat: @"<table><tr><td style='text-align:left'><b>Title</b>:</td></tr></table>"] ;
    NSString *encodedMailRecipeData = [mailRecipeData stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
    NSString *urlString = [NSString stringWithFormat:@"mailto:?subject=%@&body=%@", [@"test"  stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], encodedMailRecipeData];
    NSURL *url = [[NSURL alloc] initWithString:urlString];
    [[NSWorkspace sharedWorkspace] openURL:url];
    [urlString release];
    but for some reason when Mail application opens the body of the mail it's just plain text, can somebody help me?

    thanks!
     
  2. paos thread starter macrumors newbie

    Joined:
    Aug 13, 2009
    #2
    Is there some way to do this with applescript? can somebody help me please?
    I'm newbie on applescript, any guide will be useful . Thanks!
     
  3. robbietherobot macrumors newbie

    Joined:
    Oct 12, 2005
    #3
    What exactly are you trying to do?

    Have some experience in AppleScripting Mail. What exactly do you want to send and I can have a quick look at it.
     
  4. paos thread starter macrumors newbie

    Joined:
    Aug 13, 2009
    #4
    thank you robbietherobot :), well, what I'm trying to do is to send a custom email from an application with 2 links depending on the users choice, actually I do this on an iPhone app using the code above, but it doesn't work for mac apps, so I'm trying to do it using applescript, any help will be very appreciated .
     
  5. robbietherobot macrumors newbie

    Joined:
    Oct 12, 2005
    #5
    Simple Applescript for sending mail...

    The following should make a new mail. Uncomment out the last "send" line to send off.

    You should be able to pass what you need into your variables?

    The links should get parsed at the other end and then be clickable?

    Hope this helps. Don't understand any of that NSString stuff! Yet!...

    --Variables
    set vSubject to "Subject Line"
    set vEmailAddress to "sample@test.com"
    set vLink1 to "http://www.apple.com"
    set vLink2 to "http://www.apple.com/store"

    tell application "Mail"

    set theMessage to make new outgoing message with properties {visible:true, subject:"" & vSubject & "", content:"Body here." & return & return & vLink1 & return & return & vLink2}

    tell theMessage to make new to recipient with properties {address:vEmailAddress}

    --send theMessage

    end tell
     
  6. paos thread starter macrumors newbie

    Joined:
    Aug 13, 2009

Share This Page