• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Parsing two dates in Apple Mail for Calendar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing two dates in Apple Mail for Calendar


  • Subject: Re: Parsing two dates in Apple Mail for Calendar
  • From: Yvan KOENIG <email@hidden>
  • Date: Wed, 15 Jul 2015 22:06:17 +0200


Le 15/07/2015 à 21:57, Clay Lewis <email@hidden> a écrit :

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


Hello

I have some idea about what are doing your handlers extractBetween and parseDateString but it would have been fair to pass them to spare our time.
Without them, I already identified two anomalies in what you posted

(1) a variable is created by set starttime (with two letters t)but when you try to return it, its name become startime (with a single letter t) which is really annoying
(2) worse, you try to return a variable named endtime but you never defined it. I guess that AppleScript is a bit hungry in such a case.

Yvan KOENIG (VALLAURIS, France) mercredi 15 juillet 2015 22:06:13



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Parsing two dates in Apple Mail for Calendar (From: Clay Lewis <email@hidden>)

  • Prev by Date: Parsing two dates in Apple Mail for Calendar
  • Next by Date: Re: [PSA] native AppleScripting support for Swift
  • Previous by thread: Parsing two dates in Apple Mail for Calendar
  • Next by thread: Re: How can I get the count of these menu items?
  • Index(es):
    • Date
    • Thread