标志状态的 VBA 替换 [英] VBA Replacement for Flag Status

查看:19
本文介绍了标志状态的 VBA 替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档,Outlook 中的 MailItem.FlagStatus 属性是

您还可以通过分配给 Status 属性以编程方式设置任务项的状态,例如myTaskItem.Status = olTask​​Waiting 将状态设置为正在等待其他人".我正在尝试弄清楚如何对邮件执行相同的操作.我试图通过 myMailItem.FlagStatus 来做到这一点,但没有成功:虽然 Flag Status does 对应于某些状态,但它并不是唯一的(0 似乎等于正在进行和已推迟).由于 Flag Status 无论如何都已弃用,我认为可能有其他方法来设置这些值.

我的进步:这个页面有人提出了与我几乎完全相同的问题,答案似乎表明状态"属性被直接添加到邮件项目时被标记为待办事项.但是,我不确定以什么名称添加了任务状态.Item.Status 给我错误对象不支持此属性或方法",Item.UserProperties("Status") 也给出错误.

解决方案

我的看法是,因为 FlagIcon 和 FlagStatus 已被弃用(可能从 OL2007 开始),每个人都需要重新考虑他们的目标并修改他们的 VBA 代码.在某些时候,Outlook 将停止在这些属性中放置值(或者这些属性将消失并引发错误).

我的代码正在寻找邮件项目有后续标志但没有提醒的实例.我的规则是需要跟进的邮件应该有提醒.在新系统中,看起来邮件跟进类似于任务跟进,因此将邮件项视为任务,我的代码现在查找具有开始或截止日期且未完成但已完成的邮件项没有设置提醒,如下:

 If (myMail.TaskStartDate <> #1/1/4501# _或者 _myMail.TaskDueDate <>#1/1/4501#) _而 myMail.TaskCompletedDate = #1/1/4501# _而不是 myMail.ReminderSet 然后'在这里做点什么......万一

这比以前复杂了很多,但是面对进步你能做什么?:-D

(P.S. 如果有比#1/1/4501#"更好的编码无日期"的方法,请告诉我.)

According to documentation, the MailItem.FlagStatus property in Outlook is deprecated. So what does Outlook use to mark a mail item as "in progress" or "waiting on someone else" when said item is flagged and thus appears in the to-do list? I'd like to programatically change the status of items in the to do list, but only Task Items have the Status property and I can't figure out the correct equivalent for mail items.

While Programmatically setting a MailItem's followup flag to complete? is related, I don't believe it answers my question. The Flag Request property appears to document the associated follow up action, rather than assigning one of the standard statuses used for Task Items (Not Started, In Progress, Waiting on Someone Else, Deferred, Completed).

What I'm trying to do is this: outlook's to-do view allows you to set the Status of both task items and flagged mail items.

You can also set the status of task items programmatically by assigning to the Status property, e.g. myTaskItem.Status = olTaskWaiting sets the status to "Waiting on Someone Else". I'm trying to figure out how to do the same thing to mail items. I have attempted to do this via myMailItem.FlagStatusand been unsuccessful: while Flag Status does correspond to some of the statuses, it does not do so uniquely (0 seems to equal both In Progress and Deferred). Since Flag Status is deprecated anyway, I thought there might be some other way to set these values.

My Progress: This page has someone with nearly exactly the same question I do, and the answer seems to suggest that the "status" property is added directly to the mail item when it is flagged as a to-do. However, I'm not sure under what name task status has been added. Item.Status gives me the error "Object doesn't support this property or method", and Item.UserProperties("Status") also gives an error.

解决方案

My take on this is that because FlagIcon and FlagStatus are deprecated (and probably have been since OL2007), everyone needs to rethink their objectives and revise their VBA code. At some point, Outlook will stop putting values in those properties (or the properties will go away and throw an error).

My code was looking for instances in which a mail item had a follow-up flag but no reminder. My rule was that mail requiring follow-up should have a reminder. In the new system, it looks like mail follow-up is similar to task follow-up, so looking at the mail item as a task, my code now looks for mail items that have a start or due date and are not completed but have no reminder set, as in the following:

            If (myMail.TaskStartDate <> #1/1/4501# _
              Or _
            myMail.TaskDueDate <> #1/1/4501#) _
             And myMail.TaskCompletedDate = #1/1/4501# _
             And Not myMail.ReminderSet Then

            'Do something here ...

        End If

This is a lot more complex than before, but what can you do in the face of progress? :-D

(P.S. If there is a better way to code for "no date" than "#1/1/4501#" please let me know.)

这篇关于标志状态的 VBA 替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆