AppleScript更改Outlook签名

AppleScript更改Outlook签名,outlook,applescript,Outlook,Applescript,我为我的同事编写了一个应用程序,这样他们就可以轻松地设置Outlook签名。代码如下: property includeInRandom : false property sigName : "${signature.name}" property sigContent : "${signature.content}" try tell application "Microsoft Outlook" activate set newOutlookSignature to mak

我为我的同事编写了一个应用程序,这样他们就可以轻松地设置Outlook签名。代码如下:

property includeInRandom : false
property sigName : "${signature.name}"
property sigContent : "${signature.content}"

try
tell application "Microsoft Outlook"
    activate
    set newOutlookSignature to make new signature with properties ¬
    {name:sigName, content:sigContent, include in random:includeInRandom}
end tell
end try
问题是,如果同事在应用程序中更改签名并在Outlook中再次设置,则会有两个同名签名。是否可以检查当前签名是否已存在,如果存在,则应进行编辑/更新?

我没有Microsoft Outlook,因此无法测试我的建议,但我想您可以
获取名为sigName的每个签名,然后决定是删除所有签名并创建一个新签名,还是保留一个签名,编辑它,然后删除其余的。很明显,我是在假设随着时间的推移,可能会有0到N个签名共享一个名称。从这个角度来看,我认为删除所有签名并创建新签名是最简单的编码方式,前提是Outlook允许您删除签名列表,就像Finder允许您在单个命令中删除文件列表一样:

tell application "Microsoft Outlook" to delete every signature whose name is sigName
如果没有,则必须构造一个
repeat
循环并逐个删除它们:

tell application "Microsoft Outlook" to repeat with S in ¬
    (every signature whose name is sigName)
    set S to the contents of S  # (dereferencing)
    delete S
end repeat
如果您决定保留一个并对其进行编辑,则:

tell application "Microsoft Outlook"
    set S to every signature whose name is sigName

    if (count S) is 0 then
        # make new signature
    else
        set [R] to S
        delete the rest of S
        set the content of R to the sigContent
    end if
end tell
如果
删除其余的
不起作用,再次执行
重复
循环将允许您分别删除项目2,并仅保留要编辑的第一个项目

很抱歉,我无法为您测试这一点,但这至少表明了如何着手尝试这样做