I work for a medical research institute. We have 70+ different instruments that our researchers can schedule time on. I have implemented a scheduling system that generates an email to the user confirming their reservation. I control (to some extent) the format and content of the email. My researchers want to be able to transform this email into an appointment on their calendar. I have looked at various scripts and such (I know almost nothing about Apple Script at this point) and have cobbled together the following:
tell application “Microsoft Outlook”
-- get the currently selected message or messages
set selectedMessages to current messages
-- if there are no messages selected, warn the user and then quit
if selectedMessages is {} then
display dialog "Please select a message first and then run this script." with icon 1
return
end if
repeat with theMessage in selectedMessages
-- get the information from the message, and store it in variables
set theName to subject of theMessage
set theCategory to category of theMessage
set thePriority to priority of theMessage
set theContent to content of theMessage
set myDate to current date
-- create a new appointment with the information from the message
set newAppointment to make new calendar event with properties {subject:theName, content:theContent, start time:myDate + 1 * hours, end time:myDate + (2 * hours)}
end repeat
-- if there was only one message selected, then open that new task
if (count of selectedMessages) = 1 then open newAppointment
end tell
This does most of what I want it to do. It sets up the appointment and sets the subject line properly, it copies in the content so they can see it. What it doesn’t do is set the Starting Date/Time and Ending Date/Time properly. (I can figure out in the script it is setting the variable myDate to current date plus one hour and current date plus two hours respectively but I don’t know how to parse it for what I need) What I need it to do is to read the first two lines of content in the email (which currently looks like this - but can be changed if it would make the parsing easier:
Starting Date & Time: January 14, 2014 12:00 PM
Ending Date & Time: January 14, 2014 1:00 PM
And set the Starting Date/Time and Ending Date/Time appropriately.
Any help you could provide would be really appreciated. I really want to turn this loose to my researchers but this is a critical piece.
Thanks,
Jeff