我正在尝试实现AppleScript,以在邮箱中查找保存了外发电子邮件草稿的电子邮件。然后,找到的每个人都应打开,变成外发消息,然后发送。我已经很接近了,但是在下面的脚本中,击键命令什么也不做。它应通过调用“再次发送”将消息转换为外发消息。
using terms from application "Mail"
tell application "Mail"
set theMailbox to mailbox "OutgoingEmail" of account "iCloud"
set foundMsgs to (every message in theMailbox)
set the messageCount to the count of foundMsgs
repeat with i from 1 to the messageCount
set newMsg to item i of foundMsgs
tell newMsg
open
tell application "System Events"
tell application process "Mail"
keystroke "D" using {shift down, command down}
end tell
end tell
end tell
end repeat
end tell
end using terms from
它什么也没做。消息已打开,但按键无效。下一步是发送消息,但脚本中未显示该消息。
答案 0 :(得分:0)
我认为您不需要使用“使用邮件中的术语”命令,因为在接下来的一行中,您有一个Tell邮件块。
尝试此代码,看看它是否有效。
tell application "Mail"
set theMailbox to mailbox "OutgoingEmail" of account "iCloud"
set foundMsgs to (every message in theMailbox)
set the messageCount to the count of foundMsgs
repeat with i from 1 to the messageCount
set newMsg to item i of foundMsgs
tell newMsg
open
end tell
tell application "System Events"
tell application process "Mail"
keystroke "D" using {shift down, command down}
end tell
end tell
end repeat
end tell
还尝试仅使用系统事件命令的单独脚本,以查看它们是否可以独立运行...
tell application "System Events"
tell application process "Mail"
keystroke "D" using {shift down, command down}
end tell
end tell