AnsweredAssumed Answered

Applescript - FileMaker to Calendar

Question asked by themactech on Jul 28, 2015
Latest reply on Jul 29, 2015 by beverly

Hi everyone,

 

I had a great time at Devcon this year. I look forward to the next one.

 

If ANYONE would be kind enough to give me a hand you would be a huge hero to me.

 

I've been working on what should be a simple Applescript to take data from a FM record and create a calendar event. But I've been struggling. I thought maybe it would be easier just to have FM send email to a remote computer and create a simple Mail Rule with Applescript to create the event.. but still... it alludes me. The one reason I'm considering using Mail was that there seemed to be a long pause while FM was running the Applescript and thought it might confuse the user. But any advice would be GREATLY appreciate.

 

I have three simple text strings.. and this is what's being sent to the email

 

"July 18, 2015 12:00:00 AM"

"July 21, 2015 12:00:00 PM"

"CL-Vacation"


The first being the start date, end date and then a short description.. easy right? Well the Applescript is driving me crazy as I can't nail down the exact format. I can parts of it to work but then as a whole it just doesn't do it.


Below is the Mail Rule Script I've created. Am I missing something... if I use the Test Strings.. the Rule works but of course I want to use my variables. THANKS IN ADVANCE.


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 to paragraph 1 of msgcontent

  set endtime to paragraph 2 of msgcontent

  set mytitle to paragraph 3 of msgcontent

  set starttime to date starttime

  set endtime to date endtime

 

 

 

  end try

  end repeat

  end tell

  end perform mail action with messages

end using terms from

 

 

--TEST STRINGS

--set starttime to "July 18, 2015 12:00:00 AM"

--set endtime to "July 21, 2015 12:00:00 PM"

--set mytitle to "CL-VACATION"

 

-- Create Calendar event

tell application "Calendar" to tell calendar "Work"

  make new event with properties {start date:starttime, end date:endtime, summary:mytitle, allday event:true}

end tell

 



Outcomes