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

Mapi-Restriction does not work on Exchange



 
 
Thread Tools Search this Thread Display Modes
  #11  
Old October 4th 07, 09:30 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Mapi-Restriction does not work on Exchange

How much slower? Keep in mind that calling Restrict() will cause the
restriction to be persisted on the Exchange Server (if that is waht you are
using) potentially causing a severe performance degradation. ExecSQL
collects rows one at a time avoiding IMAPITable::Restrict() MAPI call.
You can also always use RDOItems.Restrict - it takes a SQL expression and
returns a restricted collection.
If you know there will always be only or at most one item returned, use
RDOItems.Find, followed by (if you expect more items) FindNext.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Peter Marchert" wrote in message
ups.com...
Thanks for all answers.

I use on some procedures the ExcecSQL method but it seems to be slower
than the restriction method? The code with the restriction is called
aproximately 100 times per second (or more). I create/change
appointments by looping through contact items. And on any item I have
to check if the appointment already exists.

Seems that one question is missing or I didn`t understand all answers:
Can I use the short entryid getting from an Exchange server to
reference a contact in a future Outlook session? Or is thi only the
case by using Mapi? Ken wrote in OOM I always get the long entryid but
I`m not sure if this is on Exchange so too.

Thanks Ken and Dmirty!
Peter

On 4 Okt., 20:26, "Dmitry Streblechenko" wrote:
You might want to try the new (for version 4.4) MAPITable.ExecSQL method -
you will be able to specify the conditions in the SQL format and specify
the
property names in the DASL (or OOM) format.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Peter Marchert" wrote in message

ups.com...
Yes, this was an own property created with a guid and I hard coded the
number tag by the hex value I spyed with Outlook Spy. This number tag
is different in pst and exchange. I tryed it with the GetIDsFromNames
and that works. This is my code to get the ID:

Private Function GetIdFromDaslProperty(ByVal strProperty As String) As
Long

Dim objItem As Object
Dim objSafeItem As Object
Dim PrProperty

On Error Resume Next

Set objSafeItem = CreateObject("Redemption.SafeMailItem")

Set objItem = g_objOutlook.CreateItem(olMailItem)

objSafeItem.Item = objItem

PrProperty = objSafeItem.GetIDsFromNames(DASLGUID, strProperty)

PrProperty = PrProperty + PT_STRING8

GetIdFromDaslProperty = PrProperty

Set objSafeItem.Item = Nothing
Set objSafeItem = Nothing
Set objItem = Nothing

End Function

Should this work reliably because I`m working with a unsaved mailitem?
In my test it works, but I´m not sure if it works on other machines/
configurations. Dmitry is working on the examples on his homepage with
the first item of a folder but may be the folder is empty.

Thanks for the code. PR_LONGTERM_ENTRYID_FROM_TABLE I cannot find in
Outlook Spy when opening a message on an exchange server. Where is
this property?

Last question: If a short entryid is only valid for the actual session
how can I store an id? Next time this Id may be different?
For example: Get the entryid of an contact and store it in an
appointmentitem. Outlook close and opens. Get this Id from the
appointmentitem and reference the contact. This should not work if I
understand this.

Thank you very much for your help!

Peter

On 4 Okt., 17:18, "Ken Slovak - [MVP - Outlook]"
wrote:



If this is a user property then short and long term id's don't apply.


Are you hard coding the property tag for that property or are you using
a
call to a GetIdsFromNames method?


You should always use a call to a GetIdsFromNames method for anything
other
than a standard Outlook property, even properties added by Outlook
itself
such as ReminderSet. The numeric value of the property tag will differ
from
store to store, and store provider to store provider.


If you request an EntryID from a PST provider you will always get the
same
EntryID, that's a long-term id. If you request one from an Exchange
server
you might get a short-term id that's only valid for that Outlook
session.
In
MAPI tables you always ask for both types of id's and check to see what
gets
returned. Here's the type of code I usually use for that (VB6, I can
show
C#
code if you want):


Public Const PR_ENTRYID = &HFFF0102
Public Const PR_LONGTERM_ENTRYID_FROM_TABLE = &H66700102


varColumns(0) = PR_ENTRYID
varColumns(1) = PR_LONGTERM_ENTRYID_FROM_TABLE


strEntryID = ""


If rdmFilter.FindFirst(True) Then
Row = .GetRow
If Not IsEmpty(Row) Then
strEntryID = rdmUtils.HrArrayToString(Row(1)) 'long term


If strEntryID = "" Then
strEntryID = rdmUtils.HrArrayToString(Row(0)) 'short term
End If
End If


--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment
Optionshttp://www.slovaktech.com/products.htm


"Peter Marchert" wrote in message


ups.com...
On 4 Okt., 15:43, "Ken Slovak - [MVP - Outlook]"
wrote:


What's CONTACT_ENTRY_ID, what property tag?


It is a field created by my program with the entryid of a contact
(type: PT_STRING8).


Are you accounting for the possibility with Exchange of short and long
term entryid's?


No, I don`t know the difference beteween short and long term entryids.


Thank you
Peter- Zitierten Text ausblenden -


- Zitierten Text anzeigen -




Ads
  #12  
Old October 4th 07, 09:31 PM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default Mapi-Restriction does not work on Exchange

Ok, thank you Ken.

Peter

On 4 Okt., 21:39, "Ken Slovak - [MVP - Outlook]"
wrote:
Using the Outlook object model you always get an EntryID that can be
persisted. Where you have to look out for short-term id's that are only
valid for that session is in MAPI (and Redemption). Even CDO 1.21 only
returns long-term id's.

I can't speak to the speed of ExecSQL as opposed to using a MAPI
restriction, I've only used ExecSQL in tests and in playing with things to
get the bugs squashed out of ExecSQL. I always use MAPI restrictions myself.

Dmitry can speak to the relative speed of ExecSQL better than I can.

--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm

"Peter Marchert" wrote in message

ups.com...
Thanks for all answers.

I use on some procedures the ExcecSQL method but it seems to be slower
than the restriction method? The code with the restriction is called
aproximately 100 times per second (or more). I create/change
appointments by looping through contact items. And on any item I have
to check if the appointment already exists.

Seems that one question is missing or I didn`t understand all answers:
Can I use the short entryid getting from an Exchange server to
reference a contact in a future Outlook session? Or is thi only the
case by using Mapi? Ken wrote in OOM I always get the long entryid but
I`m not sure if this is on Exchange so too.

Thanks Ken and Dmirty!
Peter



  #13  
Old October 4th 07, 10:13 PM posted to microsoft.public.outlook.program_vba
Dan Mitchell
external usenet poster
 
Posts: 58
Default Mapi-Restriction does not work on Exchange

"Dmitry Streblechenko" wrote in
:
How much slower? Keep in mind that calling Restrict() will cause the
restriction to be persisted on the Exchange Server (if that is waht
you are using) potentially causing a severe performance degradation.


http://support.microsoft.com/kb/216076

is the KB article that talks about this.

-- dan
  #14  
Old October 5th 07, 08:39 PM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default Mapi-Restriction does not work on Exchange

How much slower?

Hmm, I don`t know. I didn´t compare times by the same code with
different methods. May be there is no significant difference.

Thanks for the hint to the Find/FindNext method. I use this method in
the creation/change code and the restrict method in a function which
is not very often used.

But here is the next problem:

Public Function FindAppointment(ByVal objCalendar As Object, ByVal
strEntryID As String) As Boolean

Const RES_AND As Long = 0
Const RES_NOT As Long = 2
Const RES_OR As Long = 1
Const RES_EXIST As Long = 8
Const RES_CONTENT As Long = 3
Const FL_SUBSTRING As Long = 1
Const FL_IGNORECASE As Long = &H10000

Const PR_SUBJECT As Long = &H37001E
Const PR_ENTRYID As Long = &HFFF0102

Dim CONTACT_ENTRY_ID As Long

Dim objRDOSession As Object
Dim objUtils As Object
Dim objRow
Dim objFilter
Dim objTable

Dim objAppointment As Outlook.AppointmentItem

Dim Columns(1)
Dim objRestrOR, objRestrAND1, objRestrAND2, objRestr1
Dim objRestr1a, objRestr1b, objRestr2, objRestr2a, objRestr2b

Dim strStoreID As String

CONTACT_ENTRY_ID = GetIdFromDaslProperty("ContactEntryID")
strStoreID = objCalendar.StoreID

Set objRDOSession = CreateObject("SafeOutlook.SecureRDOSession")
objRDOSession.Logon "", "", False, False, 0

Set objUtils = CreateObject("SafeOutlook.SecureMAPIUtils")
Set objTable = CreateObject("SafeOutlook.SecureMAPITable")

objTable.Item = objRDOSession.GetFolderFromID(objCalendar.EntryID,
objCalendar.StoreID).Items

Set objFilter = objTable.Filter

objFilter.Clear

Set objRestrOR = objFilter.SetKind(RES_OR)
Set objRestrAND1 = objRestrOR.Add(RES_AND)

Set objRestr1 = objRestrAND1.Add(RES_NOT)
Set objRestr1a = objRestr1.SetKind(RES_EXIST)
objRestr1a.ulPropTag = CONTACT_ENTRY_ID

Set objRestr1b = objRestrAND1.Add(RES_CONTENT)
objRestr1b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr1b.ulPropTag = PR_SUBJECT
objRestr1b.lpProp = "Geburtstag von"

Set objRestrAND2 = objRestrOR.Add(RES_AND)

Set objRestr2a = objRestrAND2.Add(RES_EXIST)
objRestr2a.ulPropTag = CONTACT_ENTRY_ID

Set objRestr2b = objRestrAND2.Add(RES_CONTENT)
objRestr2b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr2b.ulPropTag = CONTACT_ENTRY_ID
objRestr2b.lpProp = strEntryID

Columns(0) = PR_ENTRYID
Columns(1) = CONTACT_ENTRY_ID

objTable.Columns = Columns

If objFilter.FindFirst(True) Then

Do

objRow = objTable.GetRow

If Not IsEmpty(objRow) Then
Set objAppointment =
Outlook.Session.GetItemFromID(objUtils.HrArrayToSt ring(objRow(0)),
strStoreID)
' Error: -2147221241 (80040107)
End If

Loop Until Not objFilter.FindNext(True)

End If

End Function

Interesting is the line "Set objAppointment = ...". Here araise an
error in 2007 if the folder (objCalendar) is a public folder. Same
item in the default calendar of the users mail box can be created with
out error. The item can also be created in a public folder with
2002/2003.

I´m not the Mapi-Expert and tell you only something what I have tried.
In 2002/2003 I use for RDOSessions the MAPIOBJECT method and for
2000/2007 I use the logon method. In 2000 there is no MAPIOBJECT so
there is no choose. If in 2007 I use the MAPIOBJECT some strange
things happens and will not work as expected. For example if a
RDOSession was started the user cannot longer access his folders and
have to restart Outlook. That`s the reasen to use the logon method.
Ok, but with this method the described error occurs.

Please help!

Peter

On 4 Okt., 22:30, "Dmitry Streblechenko" wrote:
How much slower? Keep in mind that calling Restrict() will cause the
restriction to be persisted on the Exchange Server (if that is waht you are
using) potentially causing a severe performance degradation. ExecSQL
collects rows one at a time avoiding IMAPITable::Restrict() MAPI call.
You can also always use RDOItems.Restrict - it takes a SQL expression and
returns a restricted collection.
If you know there will always be only or at most one item returned, use
RDOItems.Find, followed by (if you expect more items) FindNext.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Peter Marchert" wrote in message

ups.com...
Thanks for all answers.

I use on some procedures the ExcecSQL method but it seems to be slower
than the restriction method? The code with the restriction is called
aproximately 100 times per second (or more). I create/change
appointments by looping through contact items. And on any item I have
to check if the appointment already exists.

Seems that one question is missing or I didn`t understand all answers:
Can I use the short entryid getting from an Exchange server to
reference a contact in a future Outlook session? Or is thi only the
case by using Mapi? Ken wrote in OOM I always get the long entryid but
I`m not sure if this is on Exchange so too.

Thanks Ken and Dmirty!
Peter

On 4 Okt., 20:26, "Dmitry Streblechenko" wrote:



You might want to try the new (for version 4.4) MAPITable.ExecSQL method -
you will be able to specify the conditions in the SQL format and specify
the
property names in the DASL (or OOM) format.


Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Peter Marchert" wrote in message


oups.com...
Yes, this was an own property created with a guid and I hard coded the
number tag by the hex value I spyed with Outlook Spy. This number tag
is different in pst and exchange. I tryed it with the GetIDsFromNames
and that works. This is my code to get the ID:


Private Function GetIdFromDaslProperty(ByVal strProperty As String) As
Long


Dim objItem As Object
Dim objSafeItem As Object
Dim PrProperty


On Error Resume Next


Set objSafeItem = CreateObject("Redemption.SafeMailItem")


Set objItem = g_objOutlook.CreateItem(olMailItem)


objSafeItem.Item = objItem


PrProperty = objSafeItem.GetIDsFromNames(DASLGUID, strProperty)


PrProperty = PrProperty + PT_STRING8


GetIdFromDaslProperty = PrProperty


Set objSafeItem.Item = Nothing
Set objSafeItem = Nothing
Set objItem = Nothing


End Function


Should this work reliably because I`m working with a unsaved mailitem?
In my test it works, but I´m not sure if it works on other machines/
configurations. Dmitry is working on the examples on his homepage with
the first item of a folder but may be the folder is empty.


Thanks for the code. PR_LONGTERM_ENTRYID_FROM_TABLE I cannot find in
Outlook Spy when opening a message on an exchange server. Where is
this property?


Last question: If a short entryid is only valid for the actual session
how can I store an id? Next time this Id may be different?
For example: Get the entryid of an contact and store it in an
appointmentitem. Outlook close and opens. Get this Id from the
appointmentitem and reference the contact. This should not work if I
understand this.


Thank you very much for your help!


Peter


On 4 Okt., 17:18, "Ken Slovak - [MVP - Outlook]"
wrote:


If this is a user property then short and long term id's don't apply.


Are you hard coding the property tag for that property or are you using
a
call to a GetIdsFromNames method?


You should always use a call to a GetIdsFromNames method for anything
other
than a standard Outlook property, even properties added by Outlook
itself
such as ReminderSet. The numeric value of the property tag will differ
from
store to store, and store provider to store provider.


If you request an EntryID from a PST provider you will always get the
same
EntryID, that's a long-term id. If you request one from an Exchange
server
you might get a short-term id that's only valid for that Outlook
session.
In
MAPI tables you always ask for both types of id's and check to see what
gets
returned. Here's the type of code I usually use for that (VB6, I can
show
C#
code if you want):


Public Const PR_ENTRYID = &HFFF0102
Public Const PR_LONGTERM_ENTRYID_FROM_TABLE = &H66700102


varColumns(0) = PR_ENTRYID
varColumns(1) = PR_LONGTERM_ENTRYID_FROM_TABLE


strEntryID = ""


If rdmFilter.FindFirst(True) Then
Row = .GetRow
If Not IsEmpty(Row) Then
strEntryID = rdmUtils.HrArrayToString(Row(1)) 'long term


If strEntryID = "" Then
strEntryID = rdmUtils.HrArrayToString(Row(0)) 'short term
End If
End If


--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment
Optionshttp://www.slovaktech.com/products.htm


"Peter Marchert" wrote in message


ups.com...
On 4 Okt., 15:43, "Ken Slovak - [MVP - Outlook]"
wrote:


What's CONTACT_ENTRY_ID, what property tag?


It is a field created by my program with the entryid of a contact
(type: PT_STRING8).


Are you accounting for the possibility with Exchange of short and long
term entryid's?


No, I don`t know the difference beteween short and long term entryids.


Thank you
Peter- Zitierten Text ausblenden -


- Zitierten Text anzeigen -- Zitierten Text ausblenden -


- Zitierten Text anzeigen -



  #15  
Old October 5th 07, 08:39 PM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default Mapi-Restriction does not work on Exchange

Thank you Dan for this link. If I have more time and don`t forget this
post I will study this kb.

Peter

On 4 Okt., 23:13, Dan Mitchell wrote:
"Dmitry Streblechenko" wrote :

How much slower? Keep in mind that calling Restrict() will cause the
restriction to be persisted on the Exchange Server (if that is waht
you are using) potentially causing a severe performance degradation.


http://support.microsoft.com/kb/216076

is the KB article that talks about this.

-- dan



  #16  
Old October 5th 07, 09:20 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Mapi-Restriction does not work on Exchange

What is the exact error? Are you sure the item in question is really an
appointment?
The fact that you Outlook says that it can no longer display the folder
contents is a very strong indication taht you are calling RDOSession.Logoff,
which you should never be doing if you are using a shared session.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Peter Marchert" wrote in message
ups.com...
How much slower?


Hmm, I don`t know. I didn´t compare times by the same code with
different methods. May be there is no significant difference.

Thanks for the hint to the Find/FindNext method. I use this method in
the creation/change code and the restrict method in a function which
is not very often used.

But here is the next problem:

Public Function FindAppointment(ByVal objCalendar As Object, ByVal
strEntryID As String) As Boolean

Const RES_AND As Long = 0
Const RES_NOT As Long = 2
Const RES_OR As Long = 1
Const RES_EXIST As Long = 8
Const RES_CONTENT As Long = 3
Const FL_SUBSTRING As Long = 1
Const FL_IGNORECASE As Long = &H10000

Const PR_SUBJECT As Long = &H37001E
Const PR_ENTRYID As Long = &HFFF0102

Dim CONTACT_ENTRY_ID As Long

Dim objRDOSession As Object
Dim objUtils As Object
Dim objRow
Dim objFilter
Dim objTable

Dim objAppointment As Outlook.AppointmentItem

Dim Columns(1)
Dim objRestrOR, objRestrAND1, objRestrAND2, objRestr1
Dim objRestr1a, objRestr1b, objRestr2, objRestr2a, objRestr2b

Dim strStoreID As String

CONTACT_ENTRY_ID = GetIdFromDaslProperty("ContactEntryID")
strStoreID = objCalendar.StoreID

Set objRDOSession = CreateObject("SafeOutlook.SecureRDOSession")
objRDOSession.Logon "", "", False, False, 0

Set objUtils = CreateObject("SafeOutlook.SecureMAPIUtils")
Set objTable = CreateObject("SafeOutlook.SecureMAPITable")

objTable.Item = objRDOSession.GetFolderFromID(objCalendar.EntryID,
objCalendar.StoreID).Items

Set objFilter = objTable.Filter

objFilter.Clear

Set objRestrOR = objFilter.SetKind(RES_OR)
Set objRestrAND1 = objRestrOR.Add(RES_AND)

Set objRestr1 = objRestrAND1.Add(RES_NOT)
Set objRestr1a = objRestr1.SetKind(RES_EXIST)
objRestr1a.ulPropTag = CONTACT_ENTRY_ID

Set objRestr1b = objRestrAND1.Add(RES_CONTENT)
objRestr1b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr1b.ulPropTag = PR_SUBJECT
objRestr1b.lpProp = "Geburtstag von"

Set objRestrAND2 = objRestrOR.Add(RES_AND)

Set objRestr2a = objRestrAND2.Add(RES_EXIST)
objRestr2a.ulPropTag = CONTACT_ENTRY_ID

Set objRestr2b = objRestrAND2.Add(RES_CONTENT)
objRestr2b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr2b.ulPropTag = CONTACT_ENTRY_ID
objRestr2b.lpProp = strEntryID

Columns(0) = PR_ENTRYID
Columns(1) = CONTACT_ENTRY_ID

objTable.Columns = Columns

If objFilter.FindFirst(True) Then

Do

objRow = objTable.GetRow

If Not IsEmpty(objRow) Then
Set objAppointment =
Outlook.Session.GetItemFromID(objUtils.HrArrayToSt ring(objRow(0)),
strStoreID)
' Error: -2147221241 (80040107)
End If

Loop Until Not objFilter.FindNext(True)

End If

End Function

Interesting is the line "Set objAppointment = ...". Here araise an
error in 2007 if the folder (objCalendar) is a public folder. Same
item in the default calendar of the users mail box can be created with
out error. The item can also be created in a public folder with
2002/2003.

I´m not the Mapi-Expert and tell you only something what I have tried.
In 2002/2003 I use for RDOSessions the MAPIOBJECT method and for
2000/2007 I use the logon method. In 2000 there is no MAPIOBJECT so
there is no choose. If in 2007 I use the MAPIOBJECT some strange
things happens and will not work as expected. For example if a
RDOSession was started the user cannot longer access his folders and
have to restart Outlook. That`s the reasen to use the logon method.
Ok, but with this method the described error occurs.

Please help!

Peter

On 4 Okt., 22:30, "Dmitry Streblechenko" wrote:
How much slower? Keep in mind that calling Restrict() will cause the
restriction to be persisted on the Exchange Server (if that is waht you
are
using) potentially causing a severe performance degradation. ExecSQL
collects rows one at a time avoiding IMAPITable::Restrict() MAPI call.
You can also always use RDOItems.Restrict - it takes a SQL expression and
returns a restricted collection.
If you know there will always be only or at most one item returned, use
RDOItems.Find, followed by (if you expect more items) FindNext.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Peter Marchert" wrote in message

ups.com...
Thanks for all answers.

I use on some procedures the ExcecSQL method but it seems to be slower
than the restriction method? The code with the restriction is called
aproximately 100 times per second (or more). I create/change
appointments by looping through contact items. And on any item I have
to check if the appointment already exists.

Seems that one question is missing or I didn`t understand all answers:
Can I use the short entryid getting from an Exchange server to
reference a contact in a future Outlook session? Or is thi only the
case by using Mapi? Ken wrote in OOM I always get the long entryid but
I`m not sure if this is on Exchange so too.

Thanks Ken and Dmirty!
Peter

On 4 Okt., 20:26, "Dmitry Streblechenko" wrote:



You might want to try the new (for version 4.4) MAPITable.ExecSQL
method -
you will be able to specify the conditions in the SQL format and specify
the
property names in the DASL (or OOM) format.


Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Peter Marchert" wrote in message


oups.com...
Yes, this was an own property created with a guid and I hard coded the
number tag by the hex value I spyed with Outlook Spy. This number tag
is different in pst and exchange. I tryed it with the GetIDsFromNames
and that works. This is my code to get the ID:


Private Function GetIdFromDaslProperty(ByVal strProperty As String) As
Long


Dim objItem As Object
Dim objSafeItem As Object
Dim PrProperty


On Error Resume Next


Set objSafeItem = CreateObject("Redemption.SafeMailItem")


Set objItem = g_objOutlook.CreateItem(olMailItem)


objSafeItem.Item = objItem


PrProperty = objSafeItem.GetIDsFromNames(DASLGUID, strProperty)


PrProperty = PrProperty + PT_STRING8


GetIdFromDaslProperty = PrProperty


Set objSafeItem.Item = Nothing
Set objSafeItem = Nothing
Set objItem = Nothing


End Function


Should this work reliably because I`m working with a unsaved mailitem?
In my test it works, but I´m not sure if it works on other machines/
configurations. Dmitry is working on the examples on his homepage with
the first item of a folder but may be the folder is empty.


Thanks for the code. PR_LONGTERM_ENTRYID_FROM_TABLE I cannot find in
Outlook Spy when opening a message on an exchange server. Where is
this property?


Last question: If a short entryid is only valid for the actual session
how can I store an id? Next time this Id may be different?
For example: Get the entryid of an contact and store it in an
appointmentitem. Outlook close and opens. Get this Id from the
appointmentitem and reference the contact. This should not work if I
understand this.


Thank you very much for your help!


Peter


On 4 Okt., 17:18, "Ken Slovak - [MVP - Outlook]"
wrote:


If this is a user property then short and long term id's don't apply.


Are you hard coding the property tag for that property or are you
using
a
call to a GetIdsFromNames method?


You should always use a call to a GetIdsFromNames method for anything
other
than a standard Outlook property, even properties added by Outlook
itself
such as ReminderSet. The numeric value of the property tag will differ
from
store to store, and store provider to store provider.


If you request an EntryID from a PST provider you will always get the
same
EntryID, that's a long-term id. If you request one from an Exchange
server
you might get a short-term id that's only valid for that Outlook
session.
In
MAPI tables you always ask for both types of id's and check to see
what
gets
returned. Here's the type of code I usually use for that (VB6, I can
show
C#
code if you want):


Public Const PR_ENTRYID = &HFFF0102
Public Const PR_LONGTERM_ENTRYID_FROM_TABLE = &H66700102


varColumns(0) = PR_ENTRYID
varColumns(1) = PR_LONGTERM_ENTRYID_FROM_TABLE


strEntryID = ""


If rdmFilter.FindFirst(True) Then
Row = .GetRow
If Not IsEmpty(Row) Then
strEntryID = rdmUtils.HrArrayToString(Row(1)) 'long term


If strEntryID = "" Then
strEntryID = rdmUtils.HrArrayToString(Row(0)) 'short term
End If
End If


--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment
Optionshttp://www.slovaktech.com/products.htm


"Peter Marchert" wrote in message


ups.com...
On 4 Okt., 15:43, "Ken Slovak - [MVP - Outlook]"
wrote:


What's CONTACT_ENTRY_ID, what property tag?


It is a field created by my program with the entryid of a contact
(type: PT_STRING8).


Are you accounting for the possibility with Exchange of short and
long
term entryid's?


No, I don`t know the difference beteween short and long term entryids.


Thank you
Peter- Zitierten Text ausblenden -


- Zitierten Text anzeigen -- Zitierten Text ausblenden -


- Zitierten Text anzeigen -




  #17  
Old October 5th 07, 10:07 PM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default Mapi-Restriction does not work on Exchange

Thank you for your answer, Dmitry.

The error (translated by google) is "-2147221241 (80040107): A client
procedure failed". Yes, the item is an appointmentitem.

Thanks for the hint with the logoff method. I used this method because
in 2002/2003 this works fine. But now I commented the lines to logoff
out and the MAPIOBJECT works in 2007 as well. Now it is possible to
create the appointment in a public folder too.

Thank you!
Peter

On 5 Okt., 22:20, "Dmitry Streblechenko" wrote:
What is the exact error? Are you sure the item in question is really an
appointment?
The fact that you Outlook says that it can no longer display the folder
contents is a very strong indication taht you are calling RDOSession.Logoff,
which you should never be doing if you are using a shared session.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Peter Marchert" wrote in message

ups.com...

How much slower?


Hmm, I don`t know. I didn´t compare times by the same code with
different methods. May be there is no significant difference.

Thanks for the hint to the Find/FindNext method. I use this method in
the creation/change code and the restrict method in a function which
is not very often used.

But here is the next problem:

Public Function FindAppointment(ByVal objCalendar As Object, ByVal
strEntryID As String) As Boolean

Const RES_AND As Long = 0
Const RES_NOT As Long = 2
Const RES_OR As Long = 1
Const RES_EXIST As Long = 8
Const RES_CONTENT As Long = 3
Const FL_SUBSTRING As Long = 1
Const FL_IGNORECASE As Long = &H10000

Const PR_SUBJECT As Long = &H37001E
Const PR_ENTRYID As Long = &HFFF0102

Dim CONTACT_ENTRY_ID As Long

Dim objRDOSession As Object
Dim objUtils As Object
Dim objRow
Dim objFilter
Dim objTable

Dim objAppointment As Outlook.AppointmentItem

Dim Columns(1)
Dim objRestrOR, objRestrAND1, objRestrAND2, objRestr1
Dim objRestr1a, objRestr1b, objRestr2, objRestr2a, objRestr2b

Dim strStoreID As String

CONTACT_ENTRY_ID = GetIdFromDaslProperty("ContactEntryID")
strStoreID = objCalendar.StoreID

Set objRDOSession = CreateObject("SafeOutlook.SecureRDOSession")
objRDOSession.Logon "", "", False, False, 0

Set objUtils = CreateObject("SafeOutlook.SecureMAPIUtils")
Set objTable = CreateObject("SafeOutlook.SecureMAPITable")

objTable.Item = objRDOSession.GetFolderFromID(objCalendar.EntryID,
objCalendar.StoreID).Items

Set objFilter = objTable.Filter

objFilter.Clear

Set objRestrOR = objFilter.SetKind(RES_OR)
Set objRestrAND1 = objRestrOR.Add(RES_AND)

Set objRestr1 = objRestrAND1.Add(RES_NOT)
Set objRestr1a = objRestr1.SetKind(RES_EXIST)
objRestr1a.ulPropTag = CONTACT_ENTRY_ID

Set objRestr1b = objRestrAND1.Add(RES_CONTENT)
objRestr1b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr1b.ulPropTag = PR_SUBJECT
objRestr1b.lpProp = "Geburtstag von"

Set objRestrAND2 = objRestrOR.Add(RES_AND)

Set objRestr2a = objRestrAND2.Add(RES_EXIST)
objRestr2a.ulPropTag = CONTACT_ENTRY_ID

Set objRestr2b = objRestrAND2.Add(RES_CONTENT)
objRestr2b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr2b.ulPropTag = CONTACT_ENTRY_ID
objRestr2b.lpProp = strEntryID

Columns(0) = PR_ENTRYID
Columns(1) = CONTACT_ENTRY_ID

objTable.Columns = Columns

If objFilter.FindFirst(True) Then

Do

objRow = objTable.GetRow

If Not IsEmpty(objRow) Then
Set objAppointment =
Outlook.Session.GetItemFromID(objUtils.HrArrayToSt ring(objRow(0)),
strStoreID)
' Error: -2147221241 (80040107)
End If

Loop Until Not objFilter.FindNext(True)

End If

End Function

Interesting is the line "Set objAppointment = ...". Here araise an
error in 2007 if the folder (objCalendar) is a public folder. Same
item in the default calendar of the users mail box can be created with
out error. The item can also be created in a public folder with
2002/2003.

I´m not the Mapi-Expert and tell you only something what I have tried.
In 2002/2003 I use for RDOSessions the MAPIOBJECT method and for
2000/2007 I use the logon method. In 2000 there is no MAPIOBJECT so
there is no choose. If in 2007 I use the MAPIOBJECT some strange
things happens and will not work as expected. For example if a
RDOSession was started the user cannot longer access his folders and
have to restart Outlook. That`s the reasen to use the logon method.
Ok, but with this method the described error occurs.

Please help!

Peter

On 4 Okt., 22:30, "Dmitry Streblechenko" wrote:



How much slower? Keep in mind that calling Restrict() will cause the
restriction to be persisted on the Exchange Server (if that is waht you
are
using) potentially causing a severe performance degradation. ExecSQL
collects rows one at a time avoiding IMAPITable::Restrict() MAPI call.
You can also always use RDOItems.Restrict - it takes a SQL expression and
returns a restricted collection.
If you know there will always be only or at most one item returned, use
RDOItems.Find, followed by (if you expect more items) FindNext.


Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Peter Marchert" wrote in message


oups.com...
Thanks for all answers.


I use on some procedures the ExcecSQL method but it seems to be slower
than the restriction method? The code with the restriction is called
aproximately 100 times per second (or more). I create/change
appointments by looping through contact items. And on any item I have
to check if the appointment already exists.


Seems that one question is missing or I didn`t understand all answers:
Can I use the short entryid getting from an Exchange server to
reference a contact in a future Outlook session? Or is thi only the
case by using Mapi? Ken wrote in OOM I always get the long entryid but
I`m not sure if this is on Exchange so too.


Thanks Ken and Dmirty!
Peter


On 4 Okt., 20:26, "Dmitry Streblechenko" wrote:


You might want to try the new (for version 4.4) MAPITable.ExecSQL
method -
you will be able to specify the conditions in the SQL format and specify
the
property names in the DASL (or OOM) format.


Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Peter Marchert" wrote in message


oups.com...
Yes, this was an own property created with a guid and I hard coded the
number tag by the hex value I spyed with Outlook Spy. This number tag
is different in pst and exchange. I tryed it with the GetIDsFromNames
and that works. This is my code to get the ID:


Private Function GetIdFromDaslProperty(ByVal strProperty As String) As
Long


Dim objItem As Object
Dim objSafeItem As Object
Dim PrProperty


On Error Resume Next


Set objSafeItem = CreateObject("Redemption.SafeMailItem")


Set objItem = g_objOutlook.CreateItem(olMailItem)


objSafeItem.Item = objItem


PrProperty = objSafeItem.GetIDsFromNames(DASLGUID, strProperty)


PrProperty = PrProperty + PT_STRING8


GetIdFromDaslProperty = PrProperty


Set objSafeItem.Item = Nothing
Set objSafeItem = Nothing
Set objItem = Nothing


End Function


Should this work reliably because I`m working with a unsaved mailitem?
In my test it works, but I´m not sure if it works on other machines/
configurations. Dmitry is working on the examples on his homepage with
the first item of a folder but may be the folder is empty.


Thanks for the code. PR_LONGTERM_ENTRYID_FROM_TABLE I cannot find in
Outlook Spy when opening a message on an exchange server. Where is
this property?


Last question: If a short entryid is only valid for the actual session
how can I store an id? Next time this Id may be different?
For example: Get the entryid of an contact and store it in an
appointmentitem. Outlook close and opens. Get this Id from the
appointmentitem and reference the contact. This should not work if I
understand this.


Thank you very much for your help!


Peter


On 4 Okt., 17:18, "Ken Slovak - [MVP - Outlook]"
wrote:


If this is a user property then short and long term id's don't apply.


Are you hard coding the property tag for that property or are you
using
a
call to a GetIdsFromNames method?


You should always use a call to a GetIdsFromNames method for anything
other
than a standard Outlook property, even properties added by Outlook
itself
such as ReminderSet. The numeric value of the property tag will differ
from
store to store, and store provider to store provider.


If you request an EntryID from a PST provider you will always get the
same
EntryID, that's a long-term id. If you request one from an Exchange
server
you might get a short-term id that's only valid for that Outlook
session.
In
MAPI tables you always ask for both types of id's and check to see
what
gets
returned. Here's the type of code I usually use for that (VB6, I can
show
C#
code if you want):


Public Const PR_ENTRYID = &HFFF0102
Public Const PR_LONGTERM_ENTRYID_FROM_TABLE = &H66700102


varColumns(0) = PR_ENTRYID
varColumns(1) = PR_LONGTERM_ENTRYID_FROM_TABLE


strEntryID = ""


If rdmFilter.FindFirst(True) Then
Row = .GetRow
If Not IsEmpty(Row) Then
strEntryID = rdmUtils.HrArrayToString(Row(1)) 'long term


If strEntryID = "" Then
strEntryID = rdmUtils.HrArrayToString(Row(0)) 'short term
End If
End If


--


...

Erfahren Sie mehr »- Zitierten Text ausblenden -

- Zitierten Text anzeigen -



  #18  
Old October 6th 07, 12:51 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Mapi-Restriction does not work on Exchange

The error is MAPI_E_INVALID_ENTRYID.
Make sure you pass both the item entry id (EntryID property) and the parent
store entry id (Parent.StoreID), especially if you are calling
RDOSession.Logon rather than setting the RDOSession.MAPIOBJECT property.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Peter Marchert" wrote in message
ups.com...
Thank you for your answer, Dmitry.

The error (translated by google) is "-2147221241 (80040107): A client
procedure failed". Yes, the item is an appointmentitem.

Thanks for the hint with the logoff method. I used this method because
in 2002/2003 this works fine. But now I commented the lines to logoff
out and the MAPIOBJECT works in 2007 as well. Now it is possible to
create the appointment in a public folder too.

Thank you!
Peter

On 5 Okt., 22:20, "Dmitry Streblechenko" wrote:
What is the exact error? Are you sure the item in question is really an
appointment?
The fact that you Outlook says that it can no longer display the folder
contents is a very strong indication taht you are calling
RDOSession.Logoff,
which you should never be doing if you are using a shared session.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Peter Marchert" wrote in message

ups.com...

How much slower?


Hmm, I don`t know. I didn´t compare times by the same code with
different methods. May be there is no significant difference.

Thanks for the hint to the Find/FindNext method. I use this method in
the creation/change code and the restrict method in a function which
is not very often used.

But here is the next problem:

Public Function FindAppointment(ByVal objCalendar As Object, ByVal
strEntryID As String) As Boolean

Const RES_AND As Long = 0
Const RES_NOT As Long = 2
Const RES_OR As Long = 1
Const RES_EXIST As Long = 8
Const RES_CONTENT As Long = 3
Const FL_SUBSTRING As Long = 1
Const FL_IGNORECASE As Long = &H10000

Const PR_SUBJECT As Long = &H37001E
Const PR_ENTRYID As Long = &HFFF0102

Dim CONTACT_ENTRY_ID As Long

Dim objRDOSession As Object
Dim objUtils As Object
Dim objRow
Dim objFilter
Dim objTable

Dim objAppointment As Outlook.AppointmentItem

Dim Columns(1)
Dim objRestrOR, objRestrAND1, objRestrAND2, objRestr1
Dim objRestr1a, objRestr1b, objRestr2, objRestr2a, objRestr2b

Dim strStoreID As String

CONTACT_ENTRY_ID = GetIdFromDaslProperty("ContactEntryID")
strStoreID = objCalendar.StoreID

Set objRDOSession = CreateObject("SafeOutlook.SecureRDOSession")
objRDOSession.Logon "", "", False, False, 0

Set objUtils = CreateObject("SafeOutlook.SecureMAPIUtils")
Set objTable = CreateObject("SafeOutlook.SecureMAPITable")

objTable.Item = objRDOSession.GetFolderFromID(objCalendar.EntryID,
objCalendar.StoreID).Items

Set objFilter = objTable.Filter

objFilter.Clear

Set objRestrOR = objFilter.SetKind(RES_OR)
Set objRestrAND1 = objRestrOR.Add(RES_AND)

Set objRestr1 = objRestrAND1.Add(RES_NOT)
Set objRestr1a = objRestr1.SetKind(RES_EXIST)
objRestr1a.ulPropTag = CONTACT_ENTRY_ID

Set objRestr1b = objRestrAND1.Add(RES_CONTENT)
objRestr1b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr1b.ulPropTag = PR_SUBJECT
objRestr1b.lpProp = "Geburtstag von"

Set objRestrAND2 = objRestrOR.Add(RES_AND)

Set objRestr2a = objRestrAND2.Add(RES_EXIST)
objRestr2a.ulPropTag = CONTACT_ENTRY_ID

Set objRestr2b = objRestrAND2.Add(RES_CONTENT)
objRestr2b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr2b.ulPropTag = CONTACT_ENTRY_ID
objRestr2b.lpProp = strEntryID

Columns(0) = PR_ENTRYID
Columns(1) = CONTACT_ENTRY_ID

objTable.Columns = Columns

If objFilter.FindFirst(True) Then

Do

objRow = objTable.GetRow

If Not IsEmpty(objRow) Then
Set objAppointment =
Outlook.Session.GetItemFromID(objUtils.HrArrayToSt ring(objRow(0)),
strStoreID)
' Error: -2147221241 (80040107)
End If

Loop Until Not objFilter.FindNext(True)

End If

End Function

Interesting is the line "Set objAppointment = ...". Here araise an
error in 2007 if the folder (objCalendar) is a public folder. Same
item in the default calendar of the users mail box can be created with
out error. The item can also be created in a public folder with
2002/2003.

I´m not the Mapi-Expert and tell you only something what I have tried.
In 2002/2003 I use for RDOSessions the MAPIOBJECT method and for
2000/2007 I use the logon method. In 2000 there is no MAPIOBJECT so
there is no choose. If in 2007 I use the MAPIOBJECT some strange
things happens and will not work as expected. For example if a
RDOSession was started the user cannot longer access his folders and
have to restart Outlook. That`s the reasen to use the logon method.
Ok, but with this method the described error occurs.

Please help!

Peter

On 4 Okt., 22:30, "Dmitry Streblechenko" wrote:



How much slower? Keep in mind that calling Restrict() will cause the
restriction to be persisted on the Exchange Server (if that is waht you
are
using) potentially causing a severe performance degradation. ExecSQL
collects rows one at a time avoiding IMAPITable::Restrict() MAPI call.
You can also always use RDOItems.Restrict - it takes a SQL expression
and
returns a restricted collection.
If you know there will always be only or at most one item returned, use
RDOItems.Find, followed by (if you expect more items) FindNext.


Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Peter Marchert" wrote in message


oups.com...
Thanks for all answers.


I use on some procedures the ExcecSQL method but it seems to be slower
than the restriction method? The code with the restriction is called
aproximately 100 times per second (or more). I create/change
appointments by looping through contact items. And on any item I have
to check if the appointment already exists.


Seems that one question is missing or I didn`t understand all answers:
Can I use the short entryid getting from an Exchange server to
reference a contact in a future Outlook session? Or is thi only the
case by using Mapi? Ken wrote in OOM I always get the long entryid but
I`m not sure if this is on Exchange so too.


Thanks Ken and Dmirty!
Peter


On 4 Okt., 20:26, "Dmitry Streblechenko" wrote:


You might want to try the new (for version 4.4) MAPITable.ExecSQL
method -
you will be able to specify the conditions in the SQL format and
specify
the
property names in the DASL (or OOM) format.


Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Peter Marchert" wrote in message


oups.com...
Yes, this was an own property created with a guid and I hard coded the
number tag by the hex value I spyed with Outlook Spy. This number tag
is different in pst and exchange. I tryed it with the GetIDsFromNames
and that works. This is my code to get the ID:


Private Function GetIdFromDaslProperty(ByVal strProperty As String) As
Long


Dim objItem As Object
Dim objSafeItem As Object
Dim PrProperty


On Error Resume Next


Set objSafeItem = CreateObject("Redemption.SafeMailItem")


Set objItem = g_objOutlook.CreateItem(olMailItem)


objSafeItem.Item = objItem


PrProperty = objSafeItem.GetIDsFromNames(DASLGUID, strProperty)


PrProperty = PrProperty + PT_STRING8


GetIdFromDaslProperty = PrProperty


Set objSafeItem.Item = Nothing
Set objSafeItem = Nothing
Set objItem = Nothing


End Function


Should this work reliably because I`m working with a unsaved mailitem?
In my test it works, but I´m not sure if it works on other machines/
configurations. Dmitry is working on the examples on his homepage with
the first item of a folder but may be the folder is empty.


Thanks for the code. PR_LONGTERM_ENTRYID_FROM_TABLE I cannot find in
Outlook Spy when opening a message on an exchange server. Where is
this property?


Last question: If a short entryid is only valid for the actual session
how can I store an id? Next time this Id may be different?
For example: Get the entryid of an contact and store it in an
appointmentitem. Outlook close and opens. Get this Id from the
appointmentitem and reference the contact. This should not work if I
understand this.


Thank you very much for your help!


Peter


On 4 Okt., 17:18, "Ken Slovak - [MVP - Outlook]"
wrote:


If this is a user property then short and long term id's don't
apply.


Are you hard coding the property tag for that property or are you
using
a
call to a GetIdsFromNames method?


You should always use a call to a GetIdsFromNames method for
anything
other
than a standard Outlook property, even properties added by Outlook
itself
such as ReminderSet. The numeric value of the property tag will
differ
from
store to store, and store provider to store provider.


If you request an EntryID from a PST provider you will always get
the
same
EntryID, that's a long-term id. If you request one from an Exchange
server
you might get a short-term id that's only valid for that Outlook
session.
In
MAPI tables you always ask for both types of id's and check to see
what
gets
returned. Here's the type of code I usually use for that (VB6, I can
show
C#
code if you want):


Public Const PR_ENTRYID = &HFFF0102
Public Const PR_LONGTERM_ENTRYID_FROM_TABLE = &H66700102


varColumns(0) = PR_ENTRYID
varColumns(1) = PR_LONGTERM_ENTRYID_FROM_TABLE


strEntryID = ""


If rdmFilter.FindFirst(True) Then
Row = .GetRow
If Not IsEmpty(Row) Then
strEntryID = rdmUtils.HrArrayToString(Row(1)) 'long term


If strEntryID = "" Then
strEntryID = rdmUtils.HrArrayToString(Row(0)) 'short term
End If
End If


--


...

Erfahren Sie mehr »- Zitierten Text ausblenden -

- Zitierten Text anzeigen -




  #19  
Old October 7th 07, 10:15 AM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default Mapi-Restriction does not work on Exchange

Ok, I will do so.

Thank you again!
Peter

On 6 Okt., 01:51, "Dmitry Streblechenko" wrote:
The error is MAPI_E_INVALID_ENTRYID.
Make sure you pass both the item entry id (EntryID property) and the parent
store entry id (Parent.StoreID), especially if you are calling
RDOSession.Logon rather than setting the RDOSession.MAPIOBJECT property.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Peter Marchert" wrote in message

ups.com...
Thank you for your answer, Dmitry.

The error (translated by google) is "-2147221241 (80040107): A client
procedure failed". Yes, the item is an appointmentitem.

Thanks for the hint with the logoff method. I used this method because
in 2002/2003 this works fine. But now I commented the lines to logoff
out and the MAPIOBJECT works in 2007 as well. Now it is possible to
create the appointment in a public folder too.

Thank you!
Peter

On 5 Okt., 22:20, "Dmitry Streblechenko" wrote:



What is the exact error? Are you sure the item in question is really an
appointment?
The fact that you Outlook says that it can no longer display the folder
contents is a very strong indication taht you are calling
RDOSession.Logoff,
which you should never be doing if you are using a shared session.


Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Peter Marchert" wrote in message


oups.com...


How much slower?


Hmm, I don`t know. I didn´t compare times by the same code with
different methods. May be there is no significant difference.


Thanks for the hint to the Find/FindNext method. I use this method in
the creation/change code and the restrict method in a function which
is not very often used.


But here is the next problem:


Public Function FindAppointment(ByVal objCalendar As Object, ByVal
strEntryID As String) As Boolean


Const RES_AND As Long = 0
Const RES_NOT As Long = 2
Const RES_OR As Long = 1
Const RES_EXIST As Long = 8
Const RES_CONTENT As Long = 3
Const FL_SUBSTRING As Long = 1
Const FL_IGNORECASE As Long = &H10000


Const PR_SUBJECT As Long = &H37001E
Const PR_ENTRYID As Long = &HFFF0102


Dim CONTACT_ENTRY_ID As Long


Dim objRDOSession As Object
Dim objUtils As Object
Dim objRow
Dim objFilter
Dim objTable


Dim objAppointment As Outlook.AppointmentItem


Dim Columns(1)
Dim objRestrOR, objRestrAND1, objRestrAND2, objRestr1
Dim objRestr1a, objRestr1b, objRestr2, objRestr2a, objRestr2b


Dim strStoreID As String


CONTACT_ENTRY_ID = GetIdFromDaslProperty("ContactEntryID")
strStoreID = objCalendar.StoreID


Set objRDOSession = CreateObject("SafeOutlook.SecureRDOSession")
objRDOSession.Logon "", "", False, False, 0


Set objUtils = CreateObject("SafeOutlook.SecureMAPIUtils")
Set objTable = CreateObject("SafeOutlook.SecureMAPITable")


objTable.Item = objRDOSession.GetFolderFromID(objCalendar.EntryID,
objCalendar.StoreID).Items


Set objFilter = objTable.Filter


objFilter.Clear


Set objRestrOR = objFilter.SetKind(RES_OR)
Set objRestrAND1 = objRestrOR.Add(RES_AND)


Set objRestr1 = objRestrAND1.Add(RES_NOT)
Set objRestr1a = objRestr1.SetKind(RES_EXIST)
objRestr1a.ulPropTag = CONTACT_ENTRY_ID


Set objRestr1b = objRestrAND1.Add(RES_CONTENT)
objRestr1b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr1b.ulPropTag = PR_SUBJECT
objRestr1b.lpProp = "Geburtstag von"


Set objRestrAND2 = objRestrOR.Add(RES_AND)


Set objRestr2a = objRestrAND2.Add(RES_EXIST)
objRestr2a.ulPropTag = CONTACT_ENTRY_ID


Set objRestr2b = objRestrAND2.Add(RES_CONTENT)
objRestr2b.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE
objRestr2b.ulPropTag = CONTACT_ENTRY_ID
objRestr2b.lpProp = strEntryID


Columns(0) = PR_ENTRYID
Columns(1) = CONTACT_ENTRY_ID


objTable.Columns = Columns


If objFilter.FindFirst(True) Then


Do


objRow = objTable.GetRow


If Not IsEmpty(objRow) Then
Set objAppointment =
Outlook.Session.GetItemFromID(objUtils.HrArrayToSt ring(objRow(0)),
strStoreID)
' Error: -2147221241 (80040107)
End If


Loop Until Not objFilter.FindNext(True)


End If


End Function


Interesting is the line "Set objAppointment = ...". Here araise an
error in 2007 if the folder (objCalendar) is a public folder. Same
item in the default calendar of the users mail box can be created with
out error. The item can also be created in a public folder with
2002/2003.


I´m not the Mapi-Expert and tell you only something what I have tried.
In 2002/2003 I use for RDOSessions the MAPIOBJECT method and for
2000/2007 I use the logon method. In 2000 there is no MAPIOBJECT so
there is no choose. If in 2007 I use the MAPIOBJECT some strange
things happens and will not work as expected. For example if a
RDOSession was started the user cannot longer access his folders and
have to restart Outlook. That`s the reasen to use the logon method.
Ok, but with this method the described error occurs.


Please help!


Peter


On 4 Okt., 22:30, "Dmitry Streblechenko" wrote:


How much slower? Keep in mind that calling Restrict() will cause the
restriction to be persisted on the Exchange Server (if that is waht you
are
using) potentially causing a severe performance degradation. ExecSQL
collects rows one at a time avoiding IMAPITable::Restrict() MAPI call.
You can also always use RDOItems.Restrict - it takes a SQL expression
and
returns a restricted collection.
If you know there will always be only or at most one item returned, use
RDOItems.Find, followed by (if you expect more items) FindNext.


Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Peter Marchert" wrote in message


oups.com...
Thanks for all answers.


I use on some procedures the ExcecSQL method but it seems to be slower
than the restriction method? The code with the restriction is called
aproximately 100 times per second (or more). I create/change
appointments by looping through contact items. And on any item I have
to check if the appointment already exists.


Seems that one question is missing or I didn`t understand all answers:
Can I use the short entryid getting from an Exchange server to
reference a contact in a future Outlook session? Or is thi only the
case by using Mapi? Ken wrote in OOM I always get the long entryid but
I`m not sure if this is on Exchange so too.


Thanks Ken and Dmirty!
Peter


On 4 Okt., 20:26, "Dmitry Streblechenko" wrote:


You might want to try the new (for version 4.4) MAPITable.ExecSQL
method -
you will be able to specify the conditions in the SQL format and
specify
the
property names in the DASL (or OOM) format.


Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Peter Marchert" wrote in message


oups.com...
Yes, this was an own property created with a guid and I hard coded the
number tag by the hex value I spyed with Outlook Spy. This number tag
is different in pst and exchange. I tryed it with the GetIDsFromNames
and that works. This is my code to get the ID:


Private Function GetIdFromDaslProperty(ByVal strProperty As String) As
Long


Dim objItem As Object
Dim objSafeItem As Object
Dim PrProperty


On Error Resume Next


Set objSafeItem = CreateObject("Redemption.SafeMailItem")


Set objItem = g_objOutlook.CreateItem(olMailItem)


objSafeItem.Item = objItem


PrProperty = objSafeItem.GetIDsFromNames(DASLGUID, strProperty)


PrProperty = PrProperty + PT_STRING8


GetIdFromDaslProperty = PrProperty


Set objSafeItem.Item = Nothing
Set objSafeItem = Nothing
Set objItem = Nothing


End Function


Should this work reliably because I`m working with a unsaved mailitem?
In my test it works, but I´m not sure if it works on other machines/
configurations. Dmitry is working on the examples on his homepage with
the first item of a folder but may be the folder is empty.


Thanks for the code. PR_LONGTERM_ENTRYID_FROM_TABLE I cannot find in
Outlook Spy when opening a message on an exchange server. Where is
this property?


Last question: If a short entryid is only valid for the actual session
how can I store an id? Next time this Id may be different?
For example: Get the entryid of an contact and store it in an
appointmentitem. Outlook close and opens. Get this Id from the
appointmentitem and reference the contact. This should not work if I
understand this.


Thank you very much for your help!


Peter


On 4 Okt., 17:18, "Ken Slovak - [MVP - Outlook]"
wrote:


If this is a user property then short and long term id's don't
apply.


Are you hard coding the property tag for that property or are you
using
a
call to a GetIdsFromNames method?


...

Erfahren Sie mehr »- Zitierten Text ausblenden -

- Zitierten Text anzeigen -



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
need to clear restriction on email Lawrence Outlook - Installation 1 September 12th 07 06:36 PM
Restriction Joel Allen Outlook and VBA 1 May 24th 07 08:16 PM
Mail Size Restriction Donnie Darko Outlook Express 9 May 6th 07 04:26 PM
Automatic creation of Outlook/Exchange mail (MAPI) profiles script Kelly Outlook and VBA 1 November 15th 06 03:47 PM
MAPI failure with Outlook\Exchange 2003 (MAPI_E_NOT_ME) charlied Outlook - General Queries 0 February 10th 06 06:20 PM


All times are GMT +1. The time now is 11:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.