AppleScript 更改 Outlook 签名



我为我的同事编写了一个应用程序,以便他们可以轻松设置他们的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,所以我无法测试我的建议,但我想你可以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,并仅保留要编辑的第一个项目。

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

最新更新