What MAPI function is used for the Item_Add Event

G

George Hester

The reason why I am asking this is for a similar reason the Knowledge Baase
article
http://support.microsoft.com/kb/279502/en-us
OL2000: ItemRemove Event Does Not Run in Some Scenarios was written.

I am noticing that for the ItemRead event to fire a change in a UserProperty
is necessary. For example look at this code:

If TypeName(obj.Class) <> "Nothing" Then
If obj.Class = olMail Then
Set oMailItem = obj
MsgBox oMailItem.Subject & " has been added to the " &
oMailItem.Parent & " folder."
Set oscUsrProperties = oMailItem.UserProperties
If oscUsrProperties.Count > 0 Then
MsgBox "oscUsrProperties.Count = " & oscUsrProperties.Count
Set oUsrProp = oscUsrProperties.Find("MySpam")
'Here we have a MySpam property we do not go into the
following If..Then
If TypeName(oUsrProp) = "Nothing" Then
Set oUsrProp = oscUsrProperties.aDD("MySpam", olYesNo,
True, 1)
MsgBox "Added a " & oUsrProp.Name & " value."
oUsrProp.Value = False
Else
MsgBox "A " & oUsrProp.Name & " value has already been
added."
End If
Else
MsgBox "oscUsrProperties.Count = " & oscUsrProperties.Count
Set oUsrProp = oscUsrProperties.aDD("MySpam", olYesNo, True,
1)
oUsrProp.Value = False
End If
Set oInspector = oMailItem.GetInspector
'oInspector.Display
p = MsgBox("Did we call ItemRead()?", vbYesNo, "ItemRead?")
If p = vbYes Then
MsgBox "Good"
Else
MsgBox "No good but we will now..."
oMailItem_Read
p = MsgBox("Looks like we read it huh?", vbYesNo, "Forced
read!")
If p = vbYes Then
MsgBox "See, done."
Else
MsgBox "Dammit."
End If
'Err.Raise 5&
End If
End If
Else
MsgBox "TypeName(obj.Class) = " & TypeName(obj.Class)
End If
End If

If we get each If statement to be true all the way down from the top, except
this one If TypeName(oUsrProp) = "Nothing" then the ItemRead event will not
fire. As you can see I force it to later on. The code that should cause
the ItemRead event to fire is Set oInspector = oMailItem.GetInspector. But
as you can see if that code doesn't call the ItemRead event to fire I decide
to hit vbNo and it does by force. So what is it that is different in the
this path from the other paths that can be taken throgh the Ifs?

Well it must be that in the paths where the ItemRead event fires is where
the UserProperty MySpam is NOT a property of the message currently being
acted upon. That is the only difference between the path I pointed out and
the others. So I ask what MAPI function is not being used or is being used
between the path I pointed out and the others? Thanks.
 

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