Results 1 to 3 of 3
  1. #1
    tommyabroad
    Guest
    Looking for AppleScript help
    Hello,

    I'm a Newbie to Mac-Forums and to AppleScript. I can't seem to find any forums dedicated AppleScript so I will post this here as a start.

    While I have used a Mac at home for many years my recent programing has been in M$ VBA on my employers PC. Looking at AppleScript I can see some potential but the script editor is not as powerful the VBA editor when it comes to learning the language. I learn best by studying sample scripts but I have been unable to find a script that does anything like what I want to do.

    I am trying to export a large number of e-mails from OS X Mail and save them as simple text files. I am struggling to both understand the object structure and how to reference it. Therefore the information in the Dictionary doesn't help me much.

    The generic algorithm steps would go something like:
    For every message in the inbox
    if the message subject is like "ABC Corp" then
    Save message as plain text "subject.txt" in "xyz" directory
    move message to trash
    end if
    next message

    Can anyone offer some support?

    Thanks,

    TA

  2. #2
    Looking for AppleScript help
    witeshark's Avatar
    Member Since
    Mar 09, 2004
    Location
    Miami FL
    Posts
    2,860
    Specs:
    G4 1Ghz OS X 10.4.7
    Here is an example from the Applescript applications:
    using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
    tell application "Mail"
    set theText to "This AppleScript is intended to be used as an AppleScript rule action, but is also an example of how to write scripts that act on a selection of messages or mailboxes." & return & return & "To view this script, hold down the option key and select it again from the Scripts menu."
    repeat with eachMessage in theMessages
    set theSubject to subject of eachMessage
    try
    -- If this is not being executed as a rule action,
    -- getting the name of theRule variable will fail.
    set theRuleName to name of theRule
    set theText to "The rule named '" & theRuleName & "' matched this message:"
    set theText to theText & return & return & "Subject: " & theSubject
    display dialog theText
    set theText to ""
    end try
    end repeat
    if theText is not equal to "" then
    display dialog theText buttons {"OK"} default button 1
    end if
    end tell
    end perform mail action with messages
    end using terms from
    You may well be able to use this one with some modifications

  3. #3
    tommyabroad
    Guest
    Quote Originally Posted by witeshark
    [color=darkred]
    repeat with eachMessage in theMessages
    set theSubject to subject of eachMessage
    Thanks for the reply! I copied into the script editor and had to remove the first and last two lines for the syntax check to work :confused: however that brought me back to th problem i have been having looping through each message. "theMessages" is undefined. Yesterday I tried seting theMessages something like:

    tell application "Mail"
    set everyMessage to every message
    repeat with eachMessage in everyMessage
    set theSubject to subject of eachMessage
    (*code identify and so save messages*)
    end repeat
    end tell

    and I would get, NSCannontCreateScriptCommandError on "every Message"

    How do I get a set of messages, specifically the ones in the Inbox, so I can loop through them?

    Your help is appreciated.

    Thanks,

    TA

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Applescript
    By EdMarx in forum OS X - Apps and Games
    Replies: 0
    Last Post: 02-10-2012, 04:06 AM
  2. Applescript
    By SgtDave in forum OS X - Development and Darwin
    Replies: 6
    Last Post: 01-19-2011, 03:50 PM
  3. Applescript help please?
    By thtguyjosh in forum OS X - Apps and Games
    Replies: 8
    Last Post: 08-22-2010, 07:22 PM
  4. Applescript
    By nixonbw in forum OS X - Operating System
    Replies: 0
    Last Post: 07-17-2008, 07:00 PM
  5. AppleScript
    By TehHero in forum OS X - Apps and Games
    Replies: 0
    Last Post: 01-26-2008, 09:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •