Trying to get emailed schedule added to iCal automatically

I am currently trying to get my schedule which is emailed to me to automatically be added to iCal.
This is the format that my schedule comes in:
Dec 30: Monday (Not Scheduled)
Dec 31: Tuesday 12:30PM - 09:00PM
Jan 01: Wednesday (Not Scheduled)
Jan 02: Thursday (Not Scheduled)
Jan 03: Friday 12:30PM - 09:00PM
Jan 04: Saturday 03:00PM - 10:00PM
Jan 05: Sunday 04:00PM - 10:00PM
this is the code that i am currently trying to use but it does not seem to want to work
<code>
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with eachMessage in theMessages
set recivedmessage to content of eachMessage
try
set themonths to "August"
display dialog "Month is" & themonths
--display dialog recivedmessage
display dialog (characters 103 thru 554 of recivedmessage) as string
--display dialog ((characters 103 thru 108 of recivedmessage) as string) & ((characters 80 thru 86 of recivedmessage) as string)
tell application "iCal"
tell calendar "Work"
set theDate to current date
--get the month specified in the email
set givencase to ((characters 103 thru 105 of recivedmessage) as string)
--ignoring case and white space
if givencase is equal to "Aug" then
set themonth to "August"
else if givencase is equal to "Sep" then
set themonth to "September"
display dialog "Month is" & themonth
end if
--end ignoring
--create a date day, month, number, year
set myDate to ((characters 110 thru 116 of recivedmessage) as string) & ", " & themonths & " " & ((characters 107 thru 107 of recivedmessage) as string) & ((characters 80 thru 86 of recivedmessage) as string) & "6:14:36 PM"
make new event at end with properties {description:"info", summary:"Event ", location:"Event Location", start date:myDate, allday event:true}
end tell
end tell
display dialog "This is my format which is not working" & (myDate)
display dialog "This is the format " & (current date)
end try
end repeat
end tell
end perform mail action with messages
end using terms from
</code>

There are some very specific rules when creating dates from strings in AppleScript and your code doesn't follow them, which is probably why it's failing.
The specifics are touched on in the recent AppleScript release notes, but the upshot is that crafting a date from a string is tricky, at best, partly due to the numerous date formats employed around the world.
The recommended solution involves starting with a date object such as current date and changing the elements you want. This is guaranteed to work better than any string.
In addition to that I don't recommend using offsets in the text as the basis for extracting the date from the message. It's prone to errors.
I'd rework this something like:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
  tell application "Mail"
    repeat with eachMessage in theMessages
    set recivedmessage to content of eachMessage
      repeat with eachLine in receivedMessage -- iterate through each line in the message
      try
        set thisDate to (get current date) -- start with a valid date
        set {m, d} to {word 1 of eachLine, word 2 of eachLine} -- get the first two words of each line
        -- handle the day:
        set day of thisDate to d
        -- there is an easier way of doing this, but I'm lazy:
        -- handle the months:
        if m = "Jan" then
          set month of thisDate to 1
        else if m = "Feb" then
          set month of thisDate to 2
        -- and so on…
        end if
        -- rest of code to add the event to iCal goes here
        end try
      end repeat -- for each line
    end repeat -- for each message
  end tell
end perform mail action
At the end of this, you'll end up with a valid date object that you can pass to iCal as the event start date, rather than the string object you're trying to use now.

Similar Messages

  • Not connecting when trying to get email

    I have just got a problem when trying to get email. The account is Ok and connected, but next to the button Get new email (under button email) my account is grey.
    Mail program is getting mail when starting the computer. I have marked that program should get mail every five minutes, but it is not working. Neither when I am trying to get it manual.
    Tried to make a new identical account (IMAP instead of POP) and then it worked. I am though afraid of deleting my old account and lose all my old emails.
    Have repaired authorities.
    What has gone wrong?

    Please clarify -- the Get New Mail button in the toolbar of the Mail window is gray, or also if you click on Mailbox in the menubar, and choose Get New Mail, then this account is not available? But there are no symbols beside the Inbox for this account?
    Ernie
    Message was edited by: Ernie Stamper

  • How can I stop getting emails when adding events to iCal (Mac) or Calendar (iOS)?

    This question could just as well go to the iCloud on my Mac community...
    I put 'I' in the topic for brevity but it's actually my wife who gets emails every time either of us adds or edits events, whether we do it in iCal on either of our Macs or in Calendar on our iOS devices. Presumably this is to do with a setting in iCloud somewhere, but I've searched high and low and can’t find it. I've also compared settings on our Macs and phones and can't find anything that could be the culprit. It's driving her nuts!
    For more information, we share all our calendars so that either of us read and write any of them, and we're both on iOS 5.1 on our iPhones (hers is a 3GS, mine's a 4), and we're both on Mac OS X 10.7.3 Lion (2010 27" iMac and 2011 MacBook Pro respectively).

    this seems to be a new "bug" on iCloud.  It's happened to many users (judging by the posts here).  My wife and I have one shared calendar and we've been happily using it without the email problems (because I had set iCloud NOT to email us whenever an event changed - this was done at icloud.com, a setting there).  Recently we began getting emails.  I suspect a change in iCloud that was in error, because I just checked my setting and the option to have an email sent when an event changes is not checked.

  • Is there a way of getting a "schedule view" in iCal on a mac and on iPad in the same way you can get one on iPhone?

    IS there a way to get a schedule view of events on a busy day in iCal on the iPad 2 Air and on the Macbook Pro?  I can get this view on an iPhone.

    I am paranoid that some untrusted technician is going to make a copy of my music (11,000 tracks) or share some of my personal information (scanned copies of my birth certificate, passport, certificates, photos, etc.) on the web.
    If you put your info into the computer and hand it to another, you have to assume they will copy everything.
    Why are you putting scanned copies of valuable identity information into a computer than can be hacked, stolen, lost or compromised by a dirty tech?
    Have you lost your mind?
    Is there a way of finding out what activity has taken place whilst they've had it in their possession?
    No. The tech would just deny it if he did, or tell the truth which the answer would be "NO" in either case.
    The employer won't ask that sort of questions without solid proof, less they make a enemy of the employee and/or risk being sued for defamation of character.
    It's not like they bother to have a team of people watching over his shoulder that he doesn't stick a USB thumb drive of your data into his pocket to take home.
    I am paranoid that some untrusted technician is going to make a copy of my music (11,000 tracks)
    If it's iTunes music, it has your personal ID embedded into the song files. Most IT techs know this though.
    I appreciate any advice you guys can offer.
    Too late now, all you can do is not worry about it.
    Take your personal info out of the machine and if you need it, burn cd/dvd copies, a few USB thumb drives, Iron Keys or self encrypting external storage drives with key and/or keypad.

  • Server Not Available When Trying to Get Email

     For monts i've not been able to get email from my home computer , when I sign in i get a message saying server not available . what must I do in order to be able to get my email.
    {edited for privacy}

    Are you trying to access your email via webmail or an email client?
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.
    "All knowledge is worth having."

  • What is incoming server connection. Trying to get email on Samsung printer app

    I Bought a Samsung printer and trying to print emails. it is unable to connect to email. What is incoming server connection. It will print web pages

    Note that a browser-based mail request does not necessarily go through the same network path as a request by the Mail App to a POP or IMAP server.

  • Why am i getting error messages when trying to get email, why am i getting error messages when trying to get email

    For the last two evening, my email has not been coming through with Comcast email.  I get error messages like unable to verify user name and password or connection to the server has timed out.  I have done a soft reset, deleted the email account and reinstalled but nothing works.

    I had this same problem happen to me about 3 weeks ago or so. I'm with Rogers in Canada (iPhone 4).
    Out of nowhere I started having errors with both of my email accounts on my phone (Hotmail, Gmail) which I had been using without problem since I got the phone in October 2010. I tried re-entering settings, removing and setting them up from scratch again, all to no avail. First it was Hotmail but Gmail shortly followed. I could, however, check both of these emails via a browser on a computer, so I knew those services weren't both down.
    It also happened on two different wi-fi networks and with 3G.
    Then as sure as it started, it ended. It was after about 6-10 days that all my email returned to normal.
    If you've only had it happen for a few days now, I'd give it maybe another week and see if it goes away. I know this isn't a fix, and I was never able to find an explanation for the problem.

  • I keep getting the error "mail server unavailable" when trying to get email. I DO NOT have a Yahoo account.

    I keep seeing discussions about this problem with Yahoo mail, and the solution posted has just been to set up the account as an IMAP account. Unfortunately I get this error with my email (Dreamhost hosted email on my own domain) despite already having it set up for IMAP.
    Can anyone help?! This is driving me insane.

    http://support.mozilla.com/en-US/kb/Changing+the+e-mail+program+used+by+Firefox

  • When trying to get email, says "cannot connect to server"

    set up email at store, everything was fine.  then clicked mail and says "cannot connect to server", yet I can use safari, etc.  deleted and re-added the email account

    that mean your email server is having problems or unavailable at the moment.  Contact them.

  • HT5312 trying to get email to reset security questions...

    When I clicked for info on resetting my security questions,the system sent me to a page full of instructions about something else .
    iTunes system let me put my iTunes card into my account, but won't let me download til I answer security questions... one of which I can't answer.  IF, repeat IF, I input an answer to this question it was just a guess. 
    So what do I do to get an email so that I can reset the security question so I can finally download?

    If the email hasn't arrived after a few hours and isn't in a spam filter, you need to ask Apple to reset your security questions; ways of contacting them include phoning AppleCare and asking for the Account Security team, clicking here and picking a method for your country, and filling out and submitting this form.
    (105141)

  • Trying to get downloads to go into iTunes automatically

    hey all - I want my downloads from ares to go into my iTunes without adding them file by file... my friend has his go in no problem - he'll download a song, click on iTunes, and it'll already be there. i've gone into prefences and tried to do this with mine, but to no avail. i've changed the folder in ares to
    C:\Documents and Settings\Melody\My Documents\My Music\iTunes\iTunes Music
    but this doesnt help things either... i just deleted iTunes off my computer and am now redownloading it... my music is all separated in folders now (except for new downloads) - even though iTunes isnt on my computer anymore... im so confused - any help folks?
    thanks!
    ~melody~

    You need to convert the VOB files back to DV which iMovie is designed to handle. For that you need mpegStreamclip:
    http://www.apple.com/downloads/macosx/video/mpegstreamclip.html
    which is free, as well as the the Apple mpeg2 plugin :
    http://www.apple.com/quicktime/mpeg2/
    which is a mere $20.
    Another possibility is to use DVDxDV:
    http://www.dvdxdv.com/NewFolderLookSite/Products/DVDxDV.overview.htm
    which costs $25.
    Obviously the foregoing only applies to DVDs you have made yourself, or other home-made DVDs that have been given to you. It will NOT work on copy-protected commercial DVDs, which in any case would be illegal.

  • How to get a "Recently Added" playlist that automatically adds new songs you buy to that folder?

    I accidently synced my iPhone with my iPad and now my "Recently Added" folder is missing.

    Go to Controls menu.
    Select Shuffle and set to Songs.

  • Getting email in one place or another

    I am trying to get email on either iPad or desktop (entourage), but not both. Currently I get the same messages in both places. I've tried settings in both places with no luck.

    I must say that this is a most unusual request!
    Nevertheless, if your account is an IMAP account you can switch it to Pop3 and adjust the settings on the mail server so that your mails are only downloaded to the first device which accesses the server. Google SWITCHING FROM IMAP TO POP3 and see what you come up with. (I understnd that switching the other way around - from pop3 to IMAP - is virtually impossible!)

  • Getting email notifications using EWS streaming notifications for a shared mail box

    Hi,
    I have been trying to get email notification for a shared mailbox using EWS streaming notifications. i am unable to get the notifications. Please can any one tell me how this task can be achieved.
    -Praveen

    I would recommend you to this link
    http://blogs.msdn.com/b/emeamsgdev/archive/2013/04/16/ews-streaming-notification-sample.aspx
    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

  • Get email from participant

    Hello everybody! I'm trying to get email address from any participants that I have. But I have a problem...I'm using only screenflow and when I try to get Email using an automatic...I get nothing because the role for automatic is Automatic Handler. Can you help me please?
    Thnks!

    Hi,
    in PBL, to get the email from a participant you can do the following:
    p=participant.find("USER_NAME")
    em=p.email
    That way you can obtain the email adress of the participant "USER_NAME"
    Hope this helps
    regards
    --ugo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for