Re: Mysterious OSX Mail scripting problem
Re: Mysterious OSX Mail scripting problem
- Subject: Re: Mysterious OSX Mail scripting problem
- From: David Crowe <email@hidden>
- Date: Tue, 29 May 2018 13:03:44 -0600
Chris;
Thank you so much for your suggested alternatives. The account that does not
work is an IMAP account (with SSL and password authentication). OSX is El
Capitan 10.11.6
Results:
1.
tell application "Mail"
set selectedMessageList to selection
if selectedMessageList ≠ {} then
set selectedMessage to item 1 of selectedMessageList
tell selectedMessage
return subject --> Mail got an error: Can't get mailbox
"INBOX" of account "IFAST".
end tell
end if
end tell
The error message you can see above, is the same as with my method (and only
occurs with this one mailbox).
2.
tell application "Mail"
tell (some message viewer whose index is 1)
set msg to item 1 of (get selected messages)
end tell
tell msg
return subject --> Mail got an error: Can't get mailbox "INBOX"
of account "IFAST"
end tell
end tell
Unfortunately, the same error message is retrieved
3.
tell application "Mail"
tell account "IFAST"
tell mailbox "INBOX"
set theMsg to first message --> Mail got an error:
Can't get mailbox "INBOX" of account "IFAST"
tell theMsg
content
end tell
end tell
end tell
end tell
Unfortunately, this produces the same error when trying to access “first
message”
This email account otherwise works well to send and receive messages in OSX
Mail.
- David
>
> Hey David,
>
> Rule-of-the-thumb – never used that method to get selected messages.
>
> It is very fragile, and if you ever have more than one message viewer open
> it's going to break.
>
> Index 1 in this case is NOT the front message viewer.
>
> Try this instead:
>
>
> tell application "Mail"
> set selectedMessageList to selection
> if selectedMessageList ≠ {} then
> set selectedMessage to item 1 of selectedMessageList
> tell selectedMessage
> set msgSub to subject
> end tell
> end if
> end tell
>
>
> If you must use a message viewer construct then this is how to make sure the
> frontmost one is chosen.
>
> We spent a long time figuring this out many years ago, and Apple hasn't done
> anything since then to make it more sensible.
>
>
> tell application "Mail"
> tell (some message viewer whose index is 1)
> set msg to item 1 of (get selected messages)
> end tell
> tell msg
> set msgSub to subject
> end tell
> end tell
>
>
> Script 1 will work even if the front window is a message.
>
> Script 2 will NOT work UNLESS the message viewer is the FRONTMOST window.
>
>
> Are you using an IMAP or a POP account?
>
> What happens when you talk to the account like this?
>
>
> tell application "Mail"
> tell account "myGmail"
> tell mailbox "INBOX"
> set theMsg to first message
> tell theMsg
> content
> end tell
> end tell
> end tell
> end tell
>
>
> Can you talk to messages other than the selected one?
>
> What version of the macOS are you using?
>
> --
> Take Care,
> Chris
>
Attachment:
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden