View Single Post
  #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