A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , ,

What MAPI function is used for the Item_Add Event





 
 
Thread Tools Display Modes
  #1  
Old February 22nd 07, 06:39 AM posted to microsoft.public.outlook.program_vba
George Hester
external usenet poster
 
Posts: 54
Default What MAPI function is used for the Item_Add Event

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  
Old February 22nd 07, 06:55 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 1,592
Default What MAPI function is used for the Item_Add Event

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 04:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Credit Card Consolidation - Property for sale in Spain - Mortgage Loans - Buy Anything On eBay - Jewelry Necklaces