![]() |
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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hello,
there is a problem with a restriction on a MapiTable object only with Exchange. The following restriction works without problems for pst files: ' This restricton search for all appointments which ' have not the field CONTACT_ENTRY_ID and the word ' "Test" in the subject or does have the field ' CONTACT_ENTRY_ID: Set objRestrOR = objFilter.SetKind(RES_OR) Set objRestrAND = objRestrOR.Add(RES_AND) Set objRestrNOT = objRestrAND.Add(RES_NOT) Set objRestrNOTEXIST = objRestrNOT.SetKind(RES_EXIST) objRestrNOTEXIST.ulPropTag = CONTACT_ENTRY_ID Set objRestrCONTENT = objRestrAND.Add(RES_CONTENT) objRestrCONTENT.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE objRestrCONTENT.ulPropTag = PR_SUBJECT objRestrCONTENT.lpProp = "Test" Set objRestrEXIST = objRestrOR.Add(RES_EXIST) objRestrEXIST.ulPropTag = CONTACT_ENTRY_ID Same code on Exchange does nothing restrict and returns empty rows (before the restriction the rows were not empty). Peter -- Infos, workshops & software for Outlook®: www.outlook-stuff.com All software for MVP`s is free! |
Ads |
#2
|
|||
|
|||
![]()
What's CONTACT_ENTRY_ID, what property tag? Are you accounting for the
possibility with Exchange of short and long term entryid's? -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Peter Marchert" wrote in message ups.com... Hello, there is a problem with a restriction on a MapiTable object only with Exchange. The following restriction works without problems for pst files: ' This restricton search for all appointments which ' have not the field CONTACT_ENTRY_ID and the word ' "Test" in the subject or does have the field ' CONTACT_ENTRY_ID: Set objRestrOR = objFilter.SetKind(RES_OR) Set objRestrAND = objRestrOR.Add(RES_AND) Set objRestrNOT = objRestrAND.Add(RES_NOT) Set objRestrNOTEXIST = objRestrNOT.SetKind(RES_EXIST) objRestrNOTEXIST.ulPropTag = CONTACT_ENTRY_ID Set objRestrCONTENT = objRestrAND.Add(RES_CONTENT) objRestrCONTENT.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE objRestrCONTENT.ulPropTag = PR_SUBJECT objRestrCONTENT.lpProp = "Test" Set objRestrEXIST = objRestrOR.Add(RES_EXIST) objRestrEXIST.ulPropTag = CONTACT_ENTRY_ID Same code on Exchange does nothing restrict and returns empty rows (before the restriction the rows were not empty). Peter -- Infos, workshops & software for Outlook®: www.outlook-stuff.com All software for MVP`s is free! |
#3
|
|||
|
|||
![]()
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 -- 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... Hello, there is a problem with a restriction on a MapiTable object only with Exchange. The following restriction works without problems for pst files: ' This restricton search for all appointments which ' have not the field CONTACT_ENTRY_ID and the word ' "Test" in the subject or does have the field ' CONTACT_ENTRY_ID: Set objRestrOR = objFilter.SetKind(RES_OR) Set objRestrAND = objRestrOR.Add(RES_AND) Set objRestrNOT = objRestrAND.Add(RES_NOT) Set objRestrNOTEXIST = objRestrNOT.SetKind(RES_EXIST) objRestrNOTEXIST.ulPropTag = CONTACT_ENTRY_ID Set objRestrCONTENT = objRestrAND.Add(RES_CONTENT) objRestrCONTENT.ulFuzzyLevel = FL_SUBSTRING Or FL_IGNORECASE objRestrCONTENT.ulPropTag = PR_SUBJECT objRestrCONTENT.lpProp = "Test" Set objRestrEXIST = objRestrOR.Add(RES_EXIST) objRestrEXIST.ulPropTag = CONTACT_ENTRY_ID Same code on Exchange does nothing restrict and returns empty rows (before the restriction the rows were not empty). Peter -- Infos, workshops & software for Outlook®:www.outlook-stuff.com All software for MVP`s is free! |
#4
|
|||
|
|||
![]()
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 Options http://www.slovaktech.com/products.htm "Peter Marchert" wrote in message ps.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 |
#5
|
|||
|
|||
![]()
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 ps.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 |
#6
|
|||
|
|||
![]()
I don't usually use the Safe* objects, I generally use the RDO objects, but
it's pretty much the same thing. I usually add a dummy item to a folder if the folder is empty and I usually use something like RDOFolder.GetIDsFromNames. I run that code every time the application runs so I always get an accurate property tag value for the current store. If you fall back to the OOM you will always get the long-term id, so Outlook.MailItem.EntryID will always give you the long-term id. If you retrieve a short-term id you just have to know not to cache it. I've never seen PR_LONGTERM_ENTRYID_FROM_TABLE in OutlookSpy. I know about it from Dmitry, and from reading the MAPI header files in the SDK. One thing, if you use the code I showed on a PST file you will get back a valid result only from PR_ENTRY_ID, PR_LONGTERM_ENTRYID_FROM_TABLE will always be empty. I usually prefer to work with saved items for stability reasons but a user property added to an item should be OK, although of course if changes are discarded the user property will also be discarded unless a save was called at some point. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "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 |
#7
|
|||
|
|||
![]()
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 ps.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 |
#8
|
|||
|
|||
![]()
But no bit ops
![]() -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Dmitry Streblechenko" wrote in message ... 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 |
#9
|
|||
|
|||
![]()
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 - |
#10
|
|||
|
|||
![]()
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 Options http://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 |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 |