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

使用Applescript设置默认的Microsoft Outlook for Mac签名,outlook,applescript,Outlook,Applescript,我编写了一个脚本,从Active Directory获取信息,并在Microsoft Outlook for Mac中创建新签名 我使用以下代码来创建签名(我将省略其他代码,因为它并不真正相关): 其中strName是我从别处获得的签名的名称,contentHTML是我在别处构建的HTML中的实际签名 将此签名添加到Microsoft Outlook工作正常,但我看不出如何将我创建的签名设置为当前帐户的默认签名。我做了很多没有任何帮助的研究,我也翻遍了字典。这可以通过AppleScript完成。

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

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

其中strName是我从别处获得的签名的名称,contentHTML是我在别处构建的HTML中的实际签名


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

这可以通过AppleScript完成。Outlook2011字典中没有专门做这项工作的,因此可以通过编写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

恐怕这不能用AppleScript或Shell脚本完成。。Outlook 2011在其数据库中存储签名和邮件帐户,该数据库位于文件夹
/Documents/Microsoft User Data/Office 2011 identifications/Main Identity/
中。我确信从帐户到默认签名的映射在那里的某个地方,但我不知道有什么方法可以在Outlook没有注意到的情况下对其进行篡改(当数据库文件被修改时,Outlook会在下一次启动时重新构建)。感谢您的回复。我将对此进行调查:)。这种功能在Outlook中会很有用。您现在有新的方法吗?&Frank您解决了这个问题吗?您是否知道是否有可能制作一个脚本,让我的同事可以运行,并根据HTML文件安装他们的签名?(osx或MacOS上的Outlook)好吧,差不多九年后。。。现在有更好的办法吗?
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