我想重复方法在这方面非常有限。我也尝试了更通用的复制方法 - 复制了消息,但再次没有返回 ID。
这是另一种没有重复循环的可能方法:
- 创建一个新的临时类别
- 使用新类别标记原始消息
- 重复 - 重复的消息也将标有类别
- 搜索标有临时类别的消息 - 你应该只得到两个 - 原始和重复
- 删除临时类别
这是代码(相当未完成):
tell application "Microsoft Outlook"
try
set tempCategory to category "Temporary Category"
on error number -1728
set tempCategory to (make new category with properties {name:"Temporary Category"})
end try
set messageList to selected objects
set origMsg to item 1 of messageList
display dialog "Original Message ID: " & id of origMsg
set msgCat to category of origMsg
set end of msgCat to tempCategory
set category of origMsg to msgCat
duplicate origMsg to drafts
delay 1 -- sigh, it seems to take a bit of time before the category markings are reflected in the spotlight DB
--set msgList to messages whose category contains tempCategory
set currentIdentityFolder to quoted form of POSIX path of (current identity folder as string)
set tempCatMsgs to words of (do shell script "mdfind -onlyin " & currentIdentityFolder & " 'com_microsoft_outlook_categories == " & id of tempCategory & "' | xargs -I % mdls -name com_microsoft_outlook_recordID '%' | cut -d'=' -f2 | sort -u | paste -s -")
if item 1 of tempCatMsgs is (id of origMsg) as text then
set dupMsgId to item 2 of tempCatMsgs
else
set dupMsgId to item 1 of tempCatMsgs
end if
delete tempCategory
display dialog "Original Message ID: " & id of origMsg & return & "Duplicate Message ID: " & dupMsgId
end tell
我认为使用 OL 词典查找具有给定类别的消息会更容易,但不得不求助于聚光灯搜索。我确信有更好的方法来做到这一点。
向消息添加类别也比我更难 - 我再次确信这可以更有效地完成。