Applescript for mail error can't get message id

I have an applescript (found on internet) for Mail 4.5 that deletes messages in "on my mac" mailbox "Deleted Inbox" that are older than 120 days. The script runs from an iCal daily event. I drag messages from Inbox to "Deleted Inbox" when I don't want the message in Inbox, but I want to save the message for 120 days before deleting it. The script sometimes runs successfully, and sometimes gives error "Mail got an error: Can't get message id xxx of mailbox "Deleted Inbox"". Then in Mail, I "Mailbox / Rebuild" that mailbox, and run the script manually without error. How can I avoid that error? The script is essentially:
tell application "Mail"
          set OldStuff to every message of mailbox TheBox where date received of it < OldDate
          repeat with ThisMessage in OldStuff
    delete ThisMessage
          end repeat
end tell
Thanks for any help.
Ken

How can I avoid that error?
I don't actually know how you can avoid that error. However, maybe you can use a workaround and have the script rebuild the mailboxes automatically when such an error occurs. Try the following code:
tell application "Mail"
  try
    set OldStuff to every message of mailbox TheBox where date received of it < OldDate
  on error
    activate
    tell application "System Events" to click menu item "Rebuild" of menu 1 of menu bar item "Mailbox" of menu bar 1 of process "Mail"
    delay 1 -- adjust if necessary
    set OldStuff to every message of mailbox TheBox where date received of it < OldDate
  end try
  repeat with ThisMessage in OldStuff
    delete ThisMessage
  end repeat
end tell
Since the above script uses GUI Scripting, you must enable the Accessibility Frameworks by clicking the checkbox labeled "Enable access for assistive devices" in the Universal Access System Preference pane.
Message was edited by: Pierre L.

Similar Messages

  • Since I signed up for icloud, I can't get into my iweb application. I get the following message   Can't open file "/Volumes/pnoon1/Band Stufff/Domain.sites2."

    Since I signed up for icloud, I can't get into my iweb application. I get the following message 
    Can’t open file “/Volumes/pnoon1/Band Stufff/Domain.sites2.”
    Any one have any clues ????

    Hi!
    I encountered a problem a few weeks ago which is a bit like yours. In my case my Apple ID stopped working after I upgraded to Mountain Lion. I finally found out it was because of the fact that my Apple ID has in fact been an alias within my much older MobileMe/iCloud account. And they weren't able to merge or reset the account at first. It took me a lot of mails and a few calls to get them to resetting the account and changing my Apple ID (for the Apple Store, iTunes, etc.) to a different, non-iCloud related email adress.
    Anyway, maybe you can call the Apple Support and kindly ask them to reset the password for this ominous @me.com account so you can finally start using it.
    Did you try logging into iCloud using your adress with the appendix @me.com because not everybody has got the @icloud.com ending yet. Technically it's no problem to create a new iCloud account. I can understand though that you'd like to get "your name" back .

  • Finder got an error: Can't get item 1 of {document file "foo" ...}

    I have a lot of files in Corel Painter 8's RIFF format. I want to write a script that opens a file and somehow forces Corel Painter 8 to save the file as a GIF. GUI scripting may be some help with the latter; now I am concentrating on finding RIFF files and opening them in Corel Painter 8.
    I have a script that does a depth-first search of the folders starting at some root folder, using the Finder application to do the file-system stuff. It creates a list with
    set docs to every document file of pages_folder whose file type = "RIFF"
    as it loops through folders it adds to the list like this:
    set more_documents to every document file of a_folder whose file type = "RIFF"
    set docs to docs & more_documents
    My naîve mental model is that docs is a list of document-file objects. Next I have a loop that attempts to strip out files for which a GIF file already exists (and is no older than the RIFF document). This works by deleting non-matching items like so:
    if not isgifneeded then
    set docs to items 1 thru (i - 1) of docs & items (i + 1) thru (length of docs) of docs
    end if
    Finally it tries to open one of the files in Corel Painter 8 using the Finder:
    open item 1 of docs using "Corel Painter 8"
    This does not work. I get an error message
    Finder got an error: Can't get item 1 of {document file "bar" of folder "foo" of folder "blah" of folder "pdc" of folder "Users" of startup disk, ... }."
    It lists all of the files. (The error message appears in a sheet that extends off the bottom of the screen!) They are identified in the message as document-file objects. The curly braces are, I believe, the AppleScript notation for a list. I expect to be able to obtain the first element of a list with ‘item 1 of xs’. My assumption is that the Finder’s open command would expect a document file object, or at least would be able to cope with being asked to open a document. What am I missing here?
    PowerBook 12" without mini-DVI   Mac OS X (10.4.7)  

    Hi Damian and welcome to Apple Discussions!
    One suggestion: try
    tell application "Finder" to open item 1 of docs
    (without 'using "Corel Painter 8"')
    As far as the Finder is concerned, "Corel Painter 8" is just a string of characters. And telling the Finder to open a file is just the same as double-clicking it: the Finder knows which app to use - as long as these are native Corel Painter 8 docs.
    Hope this helps,
    H

  • Applescript for Mail Question

    Is it possible to create an Applescript for Mail, that, when an email with a specific subject line arrives in my inbox, an attached photograph would get sent immediately in response to the person who sent the email.  The subject lines would vary (e.g., people_1, or, places_16).  Every subject line would have a corresponding photo located somewhere on my hard drive (there would be hundreds of possibilities - the catalogue would be concentrated in one place).  So, for example, when "places_21" hits my Mail in box, an email would be generated in response, automatically, with a photo (places_21) attached.  Thank you!  Marcos

    Actually, it's not that hard to do, it's just that there are a lot of use cases, and a lot of caveats to consider.
    For example, do you intend/expect to work from a predefined list of image file names? Or do you want/expect to react to any filename that's requested?
    You say that the files would be 'somewhere on my hard drive'... how does the script know where to look? How does it resolve filename conflicts? What should happen if a file can't be found?
    As fane suggests, you should also consider an audit log, so you can see who asked for what, and when, along with errors that occurred on the way.
    So it's entirely do-able, just a lot of questions to answer before you get started.

  • Rsh[3088]: [ID 365563 daemon.error] can't get stderr port in /var/adm/mes..

    Hi,
    We are using Solaris 9 in our SF6900 cluster. On one of the node we are getting below continuous flow of messages. Please let me know what does these messages means and how to clear them.
    root@l7n2> tail -f /var/adm/messages
    Aug 8 09:09:34 l7n2 rsh[3071]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    Aug 8 09:09:34 l7n2 rsh[3075]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    Aug 8 09:09:34 l7n2 rsh[3077]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    Aug 8 09:09:34 l7n2 rsh[3078]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    Aug 8 09:09:34 l7n2 rsh[3082]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    Aug 8 09:09:34 l7n2 rsh[3084]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    Aug 8 09:09:34 l7n2 rsh[3085]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    Aug 8 09:09:34 l7n2 rsh[3086]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    Aug 8 09:09:34 l7n2 rsh[3087]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    Aug 8 09:09:34 l7n2 rsh[3088]: [ID 365563 daemon.error] can't get stderr port: Cannot assign requested address
    ^C
    Thanks.

    Hi Tom,
         Thanks, but at this point, I've rebooted, checked and double-checked more times than I'd care to count...:(
         Since I can see the NMEA strings when the GPS module is hooked-up to the USB port, I guess I'll assume there's some reason why the
         AMA0 UART has not been released, or that the GPS receives some different signals through the TTY that it's not seeing through the AMA0.
          As I mentioned, when I use 'cat /dev/ttyAMA0', it just hangs, like it's getting no data. I'll keep looking...
         Thanks for your help,
              Dave

  • IChat Error: "Can't get video from the camera"

    When I try to Screen Share with iChat on a local network, I receive the error "Can't get video from the camera" when I have an external camera plugged into the FW400 port on my Mac Mini. The Screen Sharing feature works great when the camera is not connected. Anyone know why this is and how to fix it?

    Tell us about the Network you created please.
    What make and model modem ?
    Can it route (issue IPs) ?
    IS there a router ?
    Make and model of that please ?
    If there are two devices which is doing DHCP if any are ?
    IS there any computer that is sharing it's Internet Connection with any other computer ?
    I take it from the title and the post that you infer you can Video and Audio chat ?
    The Cannot get Video from Camera normally gets and Error Log pop up.
    This can be opened with the reveal triangle on the left. The Details shown will have a Error number. Do you know what this log says ? (normally Error 20 or 21)
    Old logs are stored in Users/(your account)/Library/Logs/iChatConnectionErrors by date.
    IF you post an Error Log stop at the line that Says "Binary Images for iChat" as we don't need the bits below that yet.
    As the Screen share in iChat uses an Audio component then the Camera if it is also the Mic needs to be ON.
    In your case this may mean that in the ichat Video Menu both Camera Enabled and Mic Enabled should both be ticked.
    (I have never seen an iChat error code for not (specifically) being able to get the Mic input so the message might be the only one iChat can pop up)
    It does seem very odd that it only effecting Screen Sharing.
    I have a Firewire connected DV converter that has two Firewire ports itself so I can input the camera feed to two computers. When this is in place the System also sees it as a Network.
    I have also heard of one person with a Firewire Stills camera and I think the Storage space was seen as an External Device and therefore appeared Networked which is why I asked the first set of questions.
    iChat does not like being in Two networks (a modem that issues IP address and a router doing the same or Wireless to a neighbour and Ethernet to your Own Internet connection, the Mac being the hub in a Share Internet connection, Wireless and Ethernet to the same router and using Parallels when set to Share the Mac's IP are the most common)
    The Screen Sharing option in iChat > Video Menu is ON ? (at both ends ?)
    As iChat's Screen Sharing is related to the System Screen Sharing and therefore Apple Remote Desktop you may find that in any routing device you may have to open ports 5900 and 5988 if not using UPnP
    http://support.apple.com/kb/TS1629?viewlocale=en_US
    You said Local Network. Do you mean this is using the Bonjour Buddy List ?
    11:21 AM Saturday; June 14, 2008

  • [ID 365563 daemon.error] can't get stderr port: Cannot assign requested add

    Hello friends, i m getting the messages bellow in error logs, please suggest me what i have to do
    " [ID 365563 daemon.error] can't get stderr port: Cannot assign requested add"

    Hi Tom,
         Thanks, but at this point, I've rebooted, checked and double-checked more times than I'd care to count...:(
         Since I can see the NMEA strings when the GPS module is hooked-up to the USB port, I guess I'll assume there's some reason why the
         AMA0 UART has not been released, or that the GPS receives some different signals through the TTY that it's not seeing through the AMA0.
          As I mentioned, when I use 'cat /dev/ttyAMA0', it just hangs, like it's getting no data. I'll keep looking...
         Thanks for your help,
              Dave

  • System Events got an error: Can't get current configuration of service?

    I'm trying to connect/disconnect services through apple script, here is the error I'm getting for "Ethernet" "AirPort" (these services are configured in services tab)
    I am able to manualy On/Off these services without supplying admin password, therefore it might not be privilages issue.
    *Error message:*
    *System Events got an error: Can’t get current configuration of service id "099F7D16-4F3A-4D49-9111-A4DF0A645378" of network preferences.*
    Scipt used:
    tell application "System Events"
    tell network preferences
    tell current location
    get the name of every service
    set myService to service "AirPort"
    if exists myService then
    --get service properties of myService
    set isConnected to connected of current configuration of myService
    if isConnected then
    disconnect myService
    repeat while (get connected of current configuration of myService)
    delay 1
    end repeat
    end if
    connect myService
    end if
    end tell
    end tell
    end tell

    Hi Damian and welcome to Apple Discussions!
    One suggestion: try
    tell application "Finder" to open item 1 of docs
    (without 'using "Corel Painter 8"')
    As far as the Finder is concerned, "Corel Painter 8" is just a string of characters. And telling the Finder to open a file is just the same as double-clicking it: the Finder knows which app to use - as long as these are native Corel Painter 8 docs.
    Hope this helps,
    H

  • Import Issue : "Database error: can't get path to master" when attempting to import photos (referenced method)

    Hi Everyone,
    I have a NAS (Network Attached Storage) which holds my photos. I want to import them into Apple photos (but via the reference method).
    I did this by going to Preferences/General and unchecking the 'Importing: Copy items to the Photo library' option.
    I connect to my NAS via AFP and have mount 'Media' which is where my photos are stored.
    I select the file/import option, navigate to aforementioned photo location and select the "Review for import" button
    I then receive an error which states:
    Unreadable File
    The following files could not be imported (they may be an unrecognized file type or the files may not contain valid data).
    Filename                    Reason
    Filename.jpg              Database Error: can't get path to master
    The above error happens on multiple file types.....
    However ...
    If I tick the option in the preferences/general to 'Importing : Copy items to photo library" option then the file will import successfully.
    I of course don't want to import the files I want them to be referenced...
    Anyone else experiencing this issue????
    Thanks in advance.
    Benjamin

    If this is a 3rd party application, I would seek out that company and ask for an updated version compatible with 2010, then it would be a matter of simply installing it per their instructions.
    Otherwise, the best course of action is to deactivate the feature from WSSv3 prior to removal. If that is no longer possible, then use
    FeatureAdmin to remove the feature from within 2010.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • I;m no longer able to use the Penn State ANGEL system (I teach on line) for my email and intead get messages about "script" problems.

    Question
    I'm no longer able to use the Penn State ANGEL system (I teach on line) for my email and instead get messages about "script" problems

    I have asked a moderator to provide assistance, they will post an invite on this thread.
    They are the only BT employees on this forum, and are a UK based team of people, who take personal ownership of your problem.
    Once you get a reply, make sure that you are logged into the forum, then click on their name, you will see a screen like this. Click on the link as shown below.
    Please do not send them a personal message, as they may not be on duty for a long time, and your message will not be tracked properly.
    For your own security, do not post any personal details, on this forum. That includes any tracking number you are give.
    They will respond either by phone or e-mail within 5-6 working days.
    Please use the tracked e-mail, to reply, not via the forum. Thanks
    This is the form you should see when you click on the link. If you do not see this form, then you have selected the wrong link.
    When you submit the form, you will receive an enquiry number, so please keep a note of it
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

  • Where can I get Messaging Server 3.5 with 128-bit encryption?

    Where can I get Messaging Server 3.5 with 128-bit encryption?
    <P>
    Messaging Server 3.5 is available for export (40-bit encryption)
    and domestic (128-bit encryption). The domestic version includes
    support for Fortezza.

    It can be updated from any computer with an Internet connection but is best done from the computer which it normally syncs with. The update itself is free; if you have someone do it for you, you may be charged.
    Click here for installation instructions.
    (88299)

  • After updating to Mavericks MAIL no longer issues a "whoosh" sound when sending mail.  Can I get it back?

    After updating to Mavericks MAIL no longer issues a "whoosh" sound when sending mail.  Can I get it back?

    If restarting did not resolve the issue, open Mail Preferences and make sure the box next to "Play sounds for other mail actions" is checked.

  • I purchased additional storage for my phone not realizing it was storage for icloud. Can I get a refund?

    I purchased additional storage for my phone not realizing it was storage for icloud. Can I get a refund?

    You cannot buy additional storage for your iphone at all.
    You can contact itunes support and ask if they will allow a refund.

  • I damaged my iphone 5 and have been sent a new one, but i do not have enough storage to back up my phone and do not want to pay for more storage. can i get all of my contacts, photos, etc. on my new phone just by logging into my icloud account?

    i damaged my iphone 5 and have been sent a new one, but i do not have enough storage to back up my phone and do not want to pay for more storage. can i get all of my contacts, photos, etc. on my new phone just by logging into my icloud account?

    Not photos, just data synced with iCloud shown in Settings>iCloud.  If you don't have sufficient storage to back up to iCloud, back up to your computer instead using iTunes (connect you phone to your computer, open iTunes, click on the name of your phone in iTunes, go to ths Summary tab of your iTunes sync settings and click Back Up Now).  Also transfer your purchases to your iTunes library (connect your phone to your computer, open iTunes and go to File>Devices>Transfer Purchases). If you have photo stream photos older than 30 days tha you wan to save, save these to your camera roll before backing up (tap Select, tap the photos, tap the share icon -- box with upward facing arrow, then tap Save to Camera Roll).
    When setting up your new phone, when given the option choose Restore from iTunes Backup and restore the backup you made earlier.

  • I ordered Illustrator for another user.  I received an invitation that was accepted, logged in and tried to change the account to the name and email of the person it was ordered for.  How can I get this changed and the invitation sent to the right person?

    I ordered Illustrator via creative cloud for another user.  I received an invitation that was accepted  and tried to change the account to the name and email of the person it was ordered for.  How can I get this changed and the invitation sent to the right person? 

    Cloud as a Gift https://forums.adobe.com/thread/1665610

Maybe you are looking for

  • I just updated my OS to Leopard and know Power Point from my office suite is opening, or tries to after a reboot and hangs when you try to open it.

    I just updated my Mac Book Pro to leopard 10.6.8, and now Power Point from my office suite angs, and when I start up or re boot the laptop Power Point automatically opens and then just hangs, the only way to close is to force close. Does any one know

  • Exporting from JSP into PowerPoint or an Image file

    I am having a JSP file, the data from which need to be exported into a PowerPoint presentation. Can you suggest me some code examples of exporting the data from JSP to PowerPoint or rather to an image (.gif or .jpg), this image file can then be inser

  • Cover Flow shows desktop, or anything it likes when playing......

    Cover flow looks great, and did work, but now shows images of anywhere I've been!. Sometimes just shows white registration lines, and no artwork or images. Any ideas?. Don't understand computers, which is why I've always used a Mac......

  • WLC 5508 and CAP-1552E

    Hi , I am trying register external Wireless AP CAP-1552E  , with controller 5508 ( version 7.4.100). I have a couple of issues and I am bit confused. AP does not want to register to the controller , on layer 2 or layer 3 , even if I use DHCP option 4

  • Photoshop 7 and CS3

    I have 2 versions of Adobe Photoshop, 7 and CS3. I just ordered my new iMac and want to know if these will run on Snow Leopard? I have lots of photos that were scanned and edited in PS 7 and stored on CD. Will they open in CS5 if I am forced to buy i