![]() |
| If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|||||||
| Tags: event, function, item_add, mapi, used |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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. -- George Hester _________________________________ |
| Ads |
|
#2
|
|||
|
|||
|
There is no MAPI equivalent of the ItemRead event in OOM.
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "George Hester" wrote in message ... 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. -- George Hester _________________________________ |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with Event firing of Function MyListbox_Click() | John E. | Outlook - Using Forms | 3 | January 2nd 07 01:11 AM |
| event echo (event fires twice) vba/vb | smanky | Outlook and VBA | 0 | November 9th 06 02:16 PM |
| Problem with CommandBarComboBox Change Event (Event fires only once) | M. Khalid Farooq | Add-ins for Outlook | 1 | October 19th 06 03:34 PM |
| getting calendar event reminder for deleted event | larry.nolan@gmail.com | Outlook - General Queries | 3 | September 4th 06 03:11 PM |
| Mapi Folder Items ItemChange event is not firing | AtulSureka | Outlook and VBA | 3 | February 5th 06 07:25 PM |