0

I am working on a little script to help me organize my open messages, and I want to get every open outgoing message in Mail.app.

When I run the following I get {} back regardless of what outgoing messages I have open.

tell application "Mail"
    get every outgoing message
end tell

When I however run

tell application "Mail"
    make new outgoing message

    get every outgoing message
end tell

The first instance I get {outgoing message id 44 of application "Mail"}, the second time I get {outgoing message id 44 of application "Mail", outgoing message id 45 of application "Mail"}, etc, as it keeps opening new blank outgoing messages.

So what I'm seeing is that it can only find messages created by Applescript? Is this a bug or a feature? Is there a workaround?

donatJ
  • 3,105
  • 3
  • 32
  • 51

2 Answers2

0

The answer was on this other question here: How to set the sender of the current Mail.app outgoing message via AppleScript?

Sadly and apparently, yes, Applescript is simply broken and they haven't bothered to fix it.

Community
  • 1
  • 1
donatJ
  • 3,105
  • 3
  • 32
  • 51
0

Just to reply to "how to set the sender of the current Mail.app", you're right, the 'sender' property does not work, but you can solved it be selecting first the proper INBOX, linked to the account you want to send from, before creation of new outgoing message :see script bellow which does not involved the GUI scripting (more safe !)

tell application "Mail"
activate
if not (message viewer 1 exists) then make new message viewer
set selected mailboxes of message viewer 1 to {mailbox "INBOX" of account 2 of application "Mail"}
set newMessage to make new outgoing message with properties {visible:true, subject:"subjet xxx", content:"content free text"}
tell newMessage
    make new to recipient at end of to recipients with properties {name:"", address:"test@gmail.com"}
end tell
end tell

The words "account 2" in line 4 is the sender account (1, 2,...) and could be replaced by the name of that account like : account "my account". I hope it helps you.

pbell
  • 2,965
  • 1
  • 16
  • 13
  • Doesn't really answer my question though. I want to a be able to iterate and control open outgoing messages, and apparently you can only control ones created *with* applescript. – donatJ Oct 29 '15 at 14:51