outlook - 使用 Applescript 设置默认的 Microsoft Outlook for Mac 签名

标签 outlook applescript

我编写了一个脚本,用于从 Active Directory 获取信息并在 Microsoft Outlook for Mac 中创建新签名。

我使用以下代码来创建签名(我将忽略其他代码,因为它并不真正相关):

tell application "Microsoft Outlook"

    make new signature with properties {name:strName, content:contentHTML, plain text content:"", include in random:false}

end tell

其中 strName 是我从其他地方获得的签名的名称,contentHTML 是我在其他地方构建的 HTML 中的实际签名。

将此签名添加到 Microsoft Outlook 工作正常,但我不知道如何将我创建的签名设置为当前帐户的默认签名。我做了很多研究,但根本没有帮助,我也翻遍了字典。

最佳答案

这可以通过 AppleScript 来完成。 Outlook 2011 字典中没有专门执行此操作的内容,因此可以通过编写 UI 元素脚本来完成此操作,这无疑相当笨拙。

签名是按帐户设置的,因此您需要向此脚本提供帐户名称以及要为该帐户设置的签名名称。

setDefaultSignature to "strName" for "Gmail"

on setDefaultSignature to mySignature for accountName
  tell application "Microsoft Outlook" to activate
  tell application "System Events"
    -- turn on UI automation - may throw a permissions dialog
    if UI elements enabled is false then set UI elements enabled to true

    click menu item "Preferences..." of menu 1 of menu bar item "Outlook" of menu bar 1 of application process "Outlook"
    click item 1 of (buttons of window "Outlook Preferences" of application process "Outlook" whose description is "Signatures")
    click button "Default Signatures..." of window "Signatures" of application process "Outlook"

    repeat with thisRow in rows of table 1 of scroll area 1 of sheet 1 of window "Signatures" of application process "Outlook"
      if value of text field of thisRow as string is accountName then
        click pop up button 1 of thisRow
        click menu item mySignature of menu 1 of pop up button 1 of thisRow
        click button "OK" of sheet 1 of window "Signatures" of application process "Outlook"
        click item 1 of (buttons of window "Signatures" of application process "Outlook" whose description is "close button")
        exit repeat
      end if
    end repeat
  end tell
end setDefaultSignature

关于outlook - 使用 Applescript 设置默认的 Microsoft Outlook for Mac 签名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10089478/

相关文章:

excel - 将数据从 Excel 导出到 Outlook

c# - Outlook Redemption - 阅读电子邮件时更改默认收件箱

vba - 使用 VBA 格式化电子邮件正文

bluetooth - Applescript检查何时完成蓝牙文件交换

macos - Applescript 获取元素

macos - 使用双显示器通过 AppleScript 定位窗口

macos - AppleScript 创建 'link' 到特定的 Messages.app 对话?

macos - 如何创建 AppleScript 应用程序来运行一组终端命令

node.js - 无法使用 Nodemailer 连接到 outlook.com SMTP

vba - 迭代特定 Outlook 文件夹中的所有电子邮件项目