1

I'm new to Applescript, trying to do a basic script that gets called from a mail Rule.

Im stuck on getting the subject. There doesnt seem to be one available.

using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
        repeat with aMess in theMessages
            try
                set subj to subject of aMess
                (*
                aMess has only one property, "contents"  =
                message 1 of mailbox "Incoming POP Messages" of account id "CD180EE3-9A52-4623-BBF0-F722556AF94A"

                *)
                if subj is "" then error
            on error errMsg
                (* errMsg is 
            osascript got an error: Can’t get subject of message 1 of mailbox "Incoming POP Messages" of account id "CD180EE3-9A52-4623-BBF0-F722556AF94A".
            clearly it cant get subject because it has only "contents" property
            How to get the actual email and it's values ?
            *)
                set subj to errMsg
            end try
            display dialog "The Subject is " & subj
        end repeat
    end tell
end perform mail action with messages
end using terms from

So,

How to get the actual email and it's values ?

I thoguht that was automatic in the loop for each item.

  • Is this Mojave? Because I say "set theSubject to the subject of theMessage" all the time, but I don't use Mojave. Seems you're running into the enhanced security. – Marc Wilson Nov 26 '18 at 23:32
  • Good guess, but I'm on high Sierra 10.13.6. Mail is version 11.5 . – Greg Humphrey Nov 28 '18 at 2:23

You must log in to answer this question.

Browse other questions tagged .