问题
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.FlagStatus
and 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.
回答1:
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.)
来源:https://stackoverflow.com/questions/43987699/vba-replacement-for-flag-status