Hello
I’m rather new to applescript but I have been scouring the web for helpful tidbits. I’m working on a Mail to Calendar script and I got it almost working except I’m having trouble parsing two separate dates in the text of the email. My goal is to to have the script (via Mail rule) parse the text in the email and create a new calendar event.
The text coming in is very simple and I can format it anyway I can control what the email looks like when it’s sent but here it is.
start: Friday July 18
end: Monday July 20
titile: CL - Vacation
done
I have the Mail rule part:
-- Triggered by Mail rule.
using terms from application "Mail"
on perform mail action with messages msgs for rule theRule
tell application "Mail"
repeat with msg in msgs
try
set msgcontent to content of msg
set msgid to message id of msg
set {starttime, endtime, title} to my parseMsg(msgcontent)
my createEvent(startime, endtime, title, msgid)
end try
end repeat
end tell
end perform mail action with messages
end using terms from
Then here is the parsing part
-- Parse the email content to extract movie details.
on parseMsg(msgcontent)
set title to extractBetween(msgcontent, “title: ", " done")
set datestring to extractBetween(msgcontent, “start: ", “end: ")
set starttime to parseDateString(datestring)
return {startime, endtime, title}
end parseMsg
Then there is some other parsing and the creating of the event.. but I’m not sure how to get the end date out of the text properly.
Thanks for any advice.
Clay