【问题标题】:AppleScript change Outlook signatureAppleScript 更改 Outlook 签名
【发布时间】:2018-06-18 16:15:39
【问题描述】:

我为我的同事编写了一个应用程序,以便他们可以轻松设置 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 中设置它,则会有两个同名的签名。是否可以检查当前签名是否已经存在,如果存在则应该对其进行编辑/更新?

【问题讨论】:

    标签: outlook applescript


    【解决方案1】:

    我没有 Microsoft Outlook,所以我无法测试我的建议,但我想你可以get every signature whose name is 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
    

    如果 delete the rest of S 不起作用,repeat 循环将允许您单独删除第 2 项以后的项目,并只保留第一个要编辑的项目。

    很抱歉,我无法为您进行测试,但这至少可以说明如何尝试进行测试。

    【讨论】:

      猜你喜欢
      • 2013-02-06
      • 1970-01-01
      • 1970-01-01
      • 2021-12-14
      • 1970-01-01
      • 2013-11-28
      • 2015-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多