I’m really a beginner with AppleScript and have been tinkering with a script to send specific messages from mail and make them new events in ical. I have a preexisting script that takes specific mail messages via a rule and takes them and makes them into new todos in ical. This is the slightly modified script that I’m working with.
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with eachMessage in theMessages
set theSubject to subject of eachMessage
set theContent to content of eachMessage
try
tell application "iCal"
set newevent to (make new event in calendar "Work")
tell newevent
set summary to theSubject
set description to theContent
end tell
end tell
end try
end repeat
end tell
end perform mail action with messages
end using terms from
Here is what I’m attempting to exactly do. What I want to do is to take a given email; use a rule with the variable subject line that says: New Task Assignment; and put it in a mailbox named “Tasks”. Then I want applescript to take the subject line of the email and make it the Event Name. Then I want the body of the email to be used in two places. First, I need the script to place the whole body of the email in the notes section of the new event. Second, I need the script to take a specific line from the email body that has the due date and time of day that the task needs to be done by. The due date can be in both the “from” and “to” sections. The actual time of day that the task is due will be in the “to” section. The “from” section will be set to one hour before the actual time that the task is due ie if the task is due at 2pm the “from” section will say 1pm.
Here is what a typical email looks like:
From: shauna@hulapost.com
Subject: New Task Assignment: Please hook up the Raid in Machine Room to the G5
Date: February 26, 2008 10:08:57 PM EST
To: scott@hulapost.com
The following new task has been created on the “Hula Post” web office
site.
TASK NAME: Please hook up the Raid in Machine Room to the G5
ASSIGNED BY: Shauna
PROJECT: (none)
CATEGORY: Equipment
DUE: Friday, February 29, 2008 5:00:00 PM EST
PRIORITY: 2-Normal
STATUS: 1-Not Started
ASSIGNED TO: Chrissy, Nick, Scott, Shauna,
Terry
VISIBLE TO: Everyone
DETAILS:
Please hook up the Raid in Machine Room to the G5 Final Cut system.
If you have any questions, please check with Jonathan or Jay.
Many Thanks!
Chrissy
This task can be found at any random website.
######################################################################################################################################
Thanx in advance for your help.
Regards,
Scott
Model: MacBook Pro 2.33 3GB RAM
AppleScript: 2.1.1
Browser: Firefox 3.0b3
Operating System: Mac OS X (10.4)