为什么我在 AppleScript 命令中的击键不会将打开的电子邮件转换为"outgoing"邮件?



我正在尝试实现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

不过它什么也没做。邮件已打开,但击键不起作用。下一步是发送消息,但这不会显示在脚本中。

我认为您不需要使用"使用邮件中的术语"命令,因为您在下一行有一个用于邮件的告诉块。

尝试此代码,看看它是否有效。

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

相关内容

最新更新