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