Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8622847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:09:00+00:00 2026-06-12T07:09:00+00:00

This script has been working on 10.7 and older, but in 10.8, it seems

  • 0

This script has been working on 10.7 and older, but in 10.8, it seems it’s broken. The line:

set theFilePath to ((path to application support from user domain) as rich text) & "AppFolderName:" & UniqueName as string
set theFileReference to open for access theFilePath with write permission

Worked fine on previous versions, but Apple apparently is preventing it from working properly on Mountain Lion. Is there any other way of getting access to that folder via Apple script in Mountain Lion?

Edit: I’ve included the entire code of the script that will, within a Mail rule export the entire message to a text file that my program can import. The text file is sent to ~/Library/Application Support/MyProgram/MailImport/

Make sure the directory already exists on your machine, as it does here on mine, and the Apple Script doesn’t do any checking for it.

This script does not work when path to application support is in the code, but changing it to path to desktop work fine, meaning there is an issue writing to the application support folder, but the code works.

To test, you can create a new rule in Mail, and have Every Message run the script. You have to put the script in ~/Library/Application Scripts/com.apple.mail/

It will then appear as an option in the rules window. You can right-click a message and select Apply Rules to test the script on an individual message.

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with eachMessage in theMessages
                set sub to subject of eachMessage
                set mid to message id of eachMessage
                set sen to sender of eachMessage
                set recp to ""
                repeat with thisRecpt in recipients of eachMessage
                    set recp to recp & address of thisRecpt & ","
                end repeat
                set {year:y, month:m, day:d, hours:hh, minutes:mm} to (date sent of eachMessage)
                set dat to (y * 10000 + m * 100 + d) as string
                set tim to (hh * 100 + mm) as string
                set con to content of eachMessage

                set TotalString to "<!STDMessageSubject>" & sub & "<!STDMessageSubject>" & "<!STDMessageID>" & mid & "<!STDMessageID>" & "<!STDMessageSender>" & sen & "<!STDMessageSender>" & "<!STDMessageRecipient>" & recp & "<!STDMessageRecipient>" & "<!STDMessageDate>" & dat & "<!STDMessageDate>" & "<!STDMessageTime>" & tim & "<!STDMessageTime>" & "<!STDMessageContent>" & con & "<!STDMessageContent>"

                set UniqueName to do shell script "uuidgen"

                set theFilePath to ((path to application support from user domain) as rich text) & "MyApplication:MailImport:" & UniqueName as string
                set theFileReference to open for access theFilePath with write permission


                write TotalString to theFileReference
                close access theFileReference
            end repeat
        end tell
    end perform mail action with messages
end using terms from
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:09:01+00:00Added an answer on June 12, 2026 at 7:09 am

    So it turns out to be a Sandboxing issue. Apple Mail in 10.8 uses a Sandboxed Application Support folder location in general regardless of how hard you try to just get ~/Library/Application Support/, so from an AppleScript within Mail on 10.8

    path to application support from user domain
    

    Returns the path

    ~/Library/Containers/com.apple.mail/Data/Library/Application Support/
    

    From there the MyApplication:MailImport: folders can be created and accessed. Since our actual program that’s trying to read the output isn’t sandboxed we can just read and access the data from that location for now, as it seems to be working fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This process has been working fine in Chrome, but in Firefox 7.0.1 there are
A php script is giving this array (which has been passed through json_encode() )
I’m 100% certain this code has been working before. Now it strangely doesn’t. The
I've been working on this site for the past two weeks and everything has
This isn't my code, I'm just troubleshooting it. Some code that has been working
Hi – I've been struggling with this for days. It seems simple but I
This exact question has been asked before but I am at my wits end!
I've been working on this site - I used the phpdug script to help
This has been working for the past three weeks that I've been developing this
I am writing a simple script php. This script has to know if a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.