如何通过 AppleScript 设置当前 Mail.app 传出消息的发件人? [英] How to set the sender of the current Mail.app outgoing message via AppleScript?

查看:21
本文介绍了如何通过 AppleScript 设置当前 Mail.app 传出消息的发件人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个 AppleScript 来设置 Apple 的 Mail.app 中当前外发消息的发件人.

I'd like to write an AppleScript to set the sender of the current outgoing message in Apple's Mail.app.

我已经试过了:

tell application "Mail" to set sender of front outgoing message to "<my email address>"

但我收到错误消息 error邮件出现错误:无法将项目的发件人设置为任何."从项目发件人到任何的编号 -10006,这对我来说没有意义.

but I get the error message error "Mail got an error: Can’t set sender of item to any." number -10006 from sender of item to any which doesn't make sense to me.

当我尝试按如下方式询问前台外发消息时:

When I try to interrogate the front outgoing message as follows:

tell application "Mail" to get properties of front outgoing message

我得到 {class:item} 作为回报,而不是我期望的传出消息"对象.

I get {class:item} in return, instead of an "outgoing message" object like I'd expect.

有什么想法吗?

推荐答案

很遗憾,您无法使用 Applescript 获取或设置 Mail 的 传出消息 对象的属性.

Unfortunately, you cannot get or set the properties of the outgoing message object of Mail with Applescript.

相反,您可以使用 GUI 脚本来完成此操作,这是一种直接操作窗口元素的解决方法.

Instead, you can accomplish this with GUI scripting, a workaround that directly manipulates window elements.

此代码应该适合您:

tell application "System Events"
  tell process "Mail"
    click pop up button 1 of window 1
    click menu item 6 of menu 1 of pop up button 1 of window 1
  end tell
end tell

将第四行上的菜单项 6 更改为列表中您想要的发件人的任何数字(例如,如果您想使用此脚本更改为的发件人是列出的第四个,请更改菜单项 6菜单项 4).

Change the menu item 6 on the fourth line to whichever number in the list your desired sender is (e.g., if the sender you want to change to with this script is the fourth one listed, change menu item 6 to menu item 4).

更新:如果你很好奇,因为这个答案已经两年多了:截至 2014 年 4 月 26 日,获取/设置传出消息的属性s 仍然是不可能的,这个解决方法在 OS X 10.9 Mavericks 中仍然有效.

Update: If you're curious, since this answer is over two years old: as of 2014-04-26, getting/setting the properties of outgoing messages is still impossible and this workaround still works in OS X 10.9 Mavericks.

这篇关于如何通过 AppleScript 设置当前 Mail.app 传出消息的发件人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆