Ken,
Thank you for the explanation and code snippet. I have
Change - oSession.MAPIOBJECT = Application.Session.MAPIOBJECT
To - oAppl.GetNamespace("MAPI").MAPIOBJECT
The oFolder.Fields(&H30080040) still = Empty.
Probably something is wrong with my Outlook.
Just to confirm with you, i used OutlookSpy (IMAPIFolder) to check default
contact folder.
The GetProps tab doesn't have any PR_LAST_MODIFICATION_TIME property. How do
you check the value?
Thanks.
My code:
Dim oAppl As Outlook.Application
Dim oSession As Redemption.RDOSession
Dim oFolder As Redemption.RDOFolder
Dim oUtils As Redemption.MAPIUtils
Dim lastMod As Date
'
Set oAppl = CreateObject("Outlook.Application")
Set oSession = CreateObject("Redemption.RDOSession")
'oSession.MAPIOBJECT = Application.Session.MAPIOBJECT
oSession.MAPIOBJECT = oAppl.GetNamespace("MAPI").MAPIOBJECT
Set oUtils = CreateObject("Redemption.MAPIUtils")
oUtils.MAPIOBJECT = oSession.MAPIOBJECT
'
Set oFolder = oSession.GetDefaultFolder(olFolderContacts)
lastMod = oFolder.fields(&H30080040)
Debug.Print "UTC time: " & CStr(lastMod)
lastMod = oUtils.HrGMTToLocal(lastMod)
Debug.Print "local time: " & CStr(lastMod)
"Ken Slovak - [MVP - Outlook]" wrote:
The code works here. I used this test Sub in the Outlook VBA:
Sub TestFolderModificationDate()
Dim oSession As Redemption.rdoSession
Dim oFolder As Redemption.rdoFolder
Dim oUtils As Redemption.MAPIUtils
Dim lastMod As Date
Set oSession = CreateObject("Redemption.RDOSession")
' use Application only in Outlook VBA, otherwise get Application object,
then get NameSpace.
oSession.MAPIOBJECT = Application.Session.MAPIOBJECT
Set oUtils = CreateObject("Redemption.MAPIUtils")
oUtils.MAPIOBJECT = oSession.MAPIOBJECT
Set oFolder = oSession.GetDefaultFolder(olFolderContacts)
lastMod = oFolder.Fields(&H30080040)
Debug.Print "UTC time: " & CStr(lastMod)
lastMod = oUtils.HrGMTToLocal(lastMod)
Debug.Print "local time: " & CStr(lastMod)
End Sub
The output values matched with what I see in OutlookSpy.
Of course that test doesn't have error handling and it doesn't release
objects, etc. but it works.
Application is the Outlook.Application object intrinsically in Outlook VBA.
In Word VBA Application is Word.Application, etc.
In a VB6 COM addin you get Application passed to you in OnConnection() and
that's also a local (to that event handler) Outlook.Application object. Of
course you'd declare a variable to make that available in the rest of your
code.
--
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
"ck" wrote in message
...
Hi Ken,
I tried RDOSession but the oFolder.Fields(&H30080040) value is = Empty.
Then i tried to change the name of the contact default folder to make sure
the folder is really changed. Try again but oFolder.Fields(&H30080040)
still
empty.
By the way, you commented that:
"use Application only in Outlook VBA, otherwise get Application object,
then
get NameSpace."
Why Application only in Outlook VBA? I tried Application in VB6 Com Add-In
and it seems to work fine.
Thanks.