Skip navigation

AppleScript works for everything except Exchange server emails

1765 Views 25 Replies Latest reply: Apr 30, 2013 9:11 AM by John Galt RSS
  • Austin Kinsella1 Level 6 Level 6 (11,505 points)

    I didn't suggest the display dialog ... as a few years ago with a similar exercise it seemed to crash both Mail and Applescript, possibly because of the delay in the human response - your script can't continue until you press OK. Also, you can't use log, as that writes to Applescript Editor's window (I think) - you will have to open for access a disk file.

  • twtwtw Level 5 Level 5 (4,580 points)

    Two things to try. First, add in a 'contents of' command:

    set theSender to contents of (extract name from sender of eachMessage)

    Mail doesn't send actual values via applescript; it sends pointers to internal objects, and sometimes applescript has trouble following the indirections.  'contents of' should dereference the pointer so that you get the text value.

    The other possibility is that Exchange is sending headers in an odd order and the script is trying to process them before the the sender header arrives.  to test that, throw in a delay loop:

              repeat with i from 1 to 10

                        try

                                  set theSender to contents of (extract name from sender of eachMessage)

                                  say theSender

                                  exit repeat

                        on error

                                  delay 1

                        end try

                        if i = 10 then

                                  say "uh oh."

                                  exit repeat

                        end if

              end repeat

    That will try ten times to speak the name over as many seconds.

    Also, you don't have to wait for an email to arrive at the exchange server.  Take your other mail accounts offline (so that you don't get distractions), and then send a test email to yourself at the exchange server.  A bit like bouncing a tennis ball off a wall...

  • Jim Strong Calculating status...

    Hello John

     

    I don't know if this is going to help, but I've been successfully been using your script for some time but increasingly I've been noticing a problem in Mountain Lion that I think I have just pinned down:-

     

    I have a Gmail IMAP account and a rule to run your script on "Every Message". If the message remains in the Gmail IMAP Inbox, the script runs well and reads the sender's name. However, if I have a rule to file a message into a local folder, the script either does not speak a name - or it reads the name of whatever message is the top email in the Gmail IMAP Inbox.

     

    In other words, I believe by "Every Message" Apple Mail in Mountain Lion in fact means "Every Message in your default Inbox".

     

    Like you, the rule and script work perfectly when manually run against a selected message.

     

    I've no idea if this will help your Exchange proiblem, but thought it might assist? :-)

     

    Jim

  • Jim Strong Level 1 Level 1 (0 points)

    ..I should have added:- it doesn't matter where you place the "Every Message" rule, it seems to be affected by Rules later in the hierachy that move emails to other folders.

     

    Jim

  • Jim Strong Level 1 Level 1 (0 points)

    I think I might have tried that instead of using "every message" but have a sneaky suspicion that Mountain Lion might also be looking in the default inbox for messages addressed to my full name etc. What I have now done is - instead of moving items from my inbox to my local folder, I copy them instead - and then later delete them from the inbox.

     

    So far that seems to be working, but I do wish these workarounds were not necessary - or at least that Apple's release notes gave some better clues as to what the heck they had done to fix other reported problems!! :-)

     

    Good luck with the parameter hunt!

     

    Jim

1 2 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.