Send an Automatic Email from iCal

Discussion in 'Mac Programming' started by sammyman, Oct 15, 2007.

  1. sammyman macrumors 6502a

    Joined:
    Mar 21, 2005
    #1
    I wanted to know how to write a simple script that would automatically send an email from iCal. I just noticed one of the options for an alarm was a script. See, I organize people to teach weekly lessons, and would like to email the teacher one week in advance automatically from iCal. I have the topic for the lesson, and can write the emails now, but want them to be emailed with a script. Can anyone show me how to do this?
     
  2. Mekanik561 macrumors newbie

    Joined:
    Feb 10, 2007
    #2
    There are sample scripts on your system at:

    MacHD:Library:Scripts:Mail Scripts:

    Here's the quick and dirty.

    tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody}
    tell newMessage
    make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
    end tell
    send newMessage
    end tell
     
  3. sammyman thread starter macrumors 6502a

    Joined:
    Mar 21, 2005
    #3
    Would it be possible to have the email subject be the title of the iCal event? Thanks for the code above, BTW... I am testing it now.
     

Share This Page