MailItem flags

G

Gary E.

I've got a macro that worked in Outlook 2003 but acts funny in 2007. I wanted
a way for all messages in a conversation to have the same flag setting - you
select a message that has a flag, and the macro sets all the messages in the
same conversation to the same flag settings. This worked fine in 2003.

In the macro, after I've found all the messages in the conversation, I copy
the following settings from the selected message to each message in the
conversation:

FlagStatus
FlagDueBy
FlagRequest
FlagIcon
ReminderSet
ReminderTime

An example of the "funny" behavior: I have two messages in a conversation. I
set one message with the flag text = "Waiting", the start date to 12/21/06
and the due date to 12/22/06. But when I look at the message in VBA, I don't
find what I expect in the Flag properties. For instance, I expect FlagDueBy
to be 12/22/06, but instead it's null (1/1/4501).

Then, when I run the macro to copy the flag info to the other message in the
conversation, the other message gets the custom "Waiting" text for the flag,
but no Start and Due dates; and the message displayed in the Inbox has a big
red square where it normally displays the Category color, but no Category is
set on the message (I stepped through the macro and discovered that this
occurs when I copy the FlagIcon value from one message to another; the color
of the square changes with the value of FlagIcon, but the icon doesn't
change).

The 2007 VBA Help says that one of the differences between 2003 and 2007 is
that the FlagDueBy, FlagIcon, and FlagStatus properties are "Hidden", but it
doesn't explain what that means. I get no error in Visual Basic when I access
those properties.

I also can't find in Help what property contains the Start By date, nor an
explanation of FlagIcon values.

So how do I, in VBA, get one message to have exactly the same flag
information as another message?

--Gary
 
K

Ken Slovak - [MVP - Outlook]

Show the code in your macro.

"Hidden" in this context means that the properties will only show up in the
Object Browser if you right-click in the Object Browser's right hand pane
and select "Show Hidden Members". The intention is to hide the properties
for possible future deprecation but still allow existing code to run without
errors.

The possible values for FlagIcon are in the OlFlagIcon enumeration.

What do you mean by Start By date?

I haven't seen any problems setting any of those properties in either
Outlook 2003 or 2007 in my reminder applications.
 
K

Ken Slovak - [MVP - Outlook]

Your code works here.

I just commented out the DupQuotes line since I didn't want to bother
writing that procedure. It copies the properties correctly.

Are you using Outlook 2007 release version or a beta version?




Gary E. said:
Ken Slovak - said:
Show the code in your macro.

It's a little long, but here goes (the DupQuotes function doubles any
quote
marks it finds in the given string):

Sub SetConversationFlags()

' If the currently selected message has a flag set,
' then this macro finds all the messages within the same conversation
' and gives them the same flag values.

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim sconv As String
Dim sexpiry As String

Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
If myOlSel.Count > 1 Then
MsgBox "Please select only one message."
Exit Sub
End If

'See if the flag is set
If myOlSel.Item(1).FlagRequest = "" Then

MsgBox "No flag set."

Else

'Loop through this conversation
sconv = myOlSel.Item(1).ConversationTopic

'Open the Inbox and SentMail folders for searching
Set inbox =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Set sentmail =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail)

'Now search the Inbox for all other messages with this same
conversation topic
'(double any single quotes in the string first)
sconv = DupQuotes(sconv)
s$ = "[ConversationTopic] = '" & sconv & "'"
Set myitems = inbox.Items.Restrict(s$)
numitems = myitems.Count

'Set all of the messages in this conversation to the same flag
values
For j = 1 To numitems
Set mail = myitems(j)
mail.FlagStatus = myOlSel.Item(1).FlagStatus
mail.FlagDueBy = myOlSel.Item(1).FlagDueBy
mail.FlagRequest = myOlSel.Item(1).FlagRequest
mail.FlagIcon = myOlSel.Item(1).FlagIcon
mail.ReminderSet = myOlSel.Item(1).ReminderSet
mail.ReminderTime = myOlSel.Item(1).ReminderTime
mail.Save
Next j

'now search for the same conversation in the SentMail folder and
set
flags there
Set myitems = sentmail.Items.Restrict(s$)
numitems = myitems.Count

'Set all of the messages in this conversation to the same flag
values
For j = 1 To numitems
Set mail = myitems(j)
mail.FlagStatus = myOlSel.Item(1).FlagStatus
mail.FlagDueBy = myOlSel.Item(1).FlagDueBy
mail.FlagRequest = myOlSel.Item(1).FlagRequest
mail.FlagIcon = myOlSel.Item(1).FlagIcon
mail.ReminderSet = myOlSel.Item(1).ReminderSet
mail.ReminderTime = myOlSel.Item(1).ReminderTime
mail.Save
Next j

End If


End Sub
 
K

Ken Slovak - [MVP - Outlook]

Check ConversationIndex also. The sequence of messages in a thread uses a
base GUID with a time/date stamp appended for each succeeding message. So
the index for message #2 is x bytes longer than for message #1 and the first
n bytes are identical. I think x is 20 if I recall correctly.

That categories thing relates to changes made to flags and categories in
Outlook 2007.

It's very interesting to watch what happens to the MAPI properties on an
item when a flag and/or a reminder is set on it using a MAPI viewer such as
OutlookSpy.
 
K

Ken Slovak - [MVP - Outlook]

The old flags have been changed by Outlook 2007, if you look at the flagging
options you will see how much they've changed. Use a MAPI viewer such as
OutlookSpy to examine the properties on an item that you set to one of the
new flags to see what you should use in your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top