• 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
Parsing two dates in Apple Mail for Calendar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parsing two dates in Apple Mail for Calendar


  • Subject: Parsing two dates in Apple Mail for Calendar
  • From: Clay Lewis <email@hidden>
  • Date: Wed, 15 Jul 2015 15:57:13 -0400

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


 _______________________________________________
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

  • Follow-Ups:
    • Re: Parsing two dates in Apple Mail for Calendar
      • From: Yvan KOENIG <email@hidden>
  • Prev by Date: [PSA] native AppleScripting support for Swift
  • Next by Date: Re: Parsing two dates in Apple Mail for Calendar
  • Previous by thread: Re: [PSA] native AppleScripting support for Swift
  • Next by thread: Re: Parsing two dates in Apple Mail for Calendar
  • Index(es):
    • Date
    • Thread