gpt4 book ai didi

macos - Applescript 删除 Outlook 2011 中某个类别的邮件

转载 作者:行者123 更新时间:2023-12-02 03:34:47 25 4
gpt4 key购买 nike

上下文

在 Outlook 2011 中,我有一个自动设置传入邮件类别的规则 - 例如“紫色类别”。我希望该类别的电子邮件在一周后自动删除。

我想使用 AppleScript 选择收件箱中“紫色类别”中的所有邮件以及一周前的邮件,并将它们移至已删除的文件夹。

问题

问题是我无法使用 Applescript 选择紫色类别中的消息。从 Outlook Dictionary 的描述来看,messagecategory 似乎在同一级别:

以下是 Outlook 词典中对这两项的描述:

category n, pl categories [inh. object > item] : A category.

contained by application.


message n [inh. todoable object > categorizable object > object > item; see also Debug Suite] : An e-mail message.

contains recipients, to recipients, cc recipients, bcc recipients, attachments;

contained by application, mail folders.

如您所见,当我尝试时,两者都包含在应用程序中,所以在 AppleScript 中:

set messagesToDelete to message in inbox whose {category "Purple Category"}

我收到一条错误消息:

Can’t get message of inbox of application "Microsoft Outlook" whose {category "Purple Category"}. Access not allowed.

其余代码:

set daysToPreserve to 7
set dateReference to (current date) - (daysToPreserve * days)
tell application "Microsoft Outlook"
set messagesToDelete to message in inbox whose {category "Purple Category"} and time received ≤ dateReference
if messagesToDelete is {} then
return
end if
permanently delete messagesToDelete
end tell
display dialog (count messagesToDelete) & " old Mail Messages Have Been Purged" as text buttons ["OK"]

最佳答案

你必须遍历所有有类别的消息

tell application "Microsoft Outlook"

repeat with afolder in mail folders
set theMsgs to (every message of afolder where it's category is not {})

-- loop through the messages
repeat with aMsg in theMsgs
-- get all the categories of the message
set cats to categories of aMsg
-- loop through the categories
repeat with aCat in cats
set catName to name of aCat
-- check to see if this is the category of emails we want to delete
if catName is "Purple Category" then
get time received of aMsg
set foo to date of time received of aMsg
-- compare dates and delete aMsg
-- exit the loop so we don't error after deleting the message
exit repeat
end if
end repeat
end repeat
end repeat
end tell

关于macos - Applescript 删除 Outlook 2011 中某个类别的邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24337274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com