Setting Folder Aging Properties Prob

G

Guest

Can you post a sample of your code?

This is some code I have for changing the auto-archive settings:

Sub ReadFolderAgingProperties()
Dim objFolder As MAPI.Folder
Dim objMessage As MAPI.Message
Dim objSession As MAPI.Session
Dim objField As MAPI.Field
Set objSession = New MAPI.Session

objSession.Logon , , , False

Set objFolder =
objSession.GetFolder(Application.ActiveExplorer.CurrentFolder.EntryID)
For Each objMessage In objFolder.HiddenMessages
If objMessage.Type = "IPC.MS.Outlook.AgingProperties" Then
' Change the autoarchive mode (none,default,param)
objMessage.Fields.Item(CdoPR_AUTOARCHIVE_TYPE).Value = 0
' Change aging properties to 14 months/weeks/days
objMessage.Fields.Item(CdoPR_AGING_PERIOD).Value = 3
' Change aging granularity to days
objMessage.Fields.Item(CdoPR_AGING_GRANULARITY).Value = AG_MONTHS
' Change the path to the archive file
objMessage.Fields.Item(CdoPR_AGING_PATH).Value =
"C:\Temp\archive.pst"
' Enable aging for this folder
objMessage.Fields.Item(CdoPR_AGING_ENABLED).Value = True
' Enable aging age for this folder
objMessage.Fields.Item(CdoPR_AGING_AGE_FOLDER).Value = True
' Update hidden message
objMessage.Update True, True
End If
Next

Set objFolder = Nothing
Set objMessage = Nothing
objSession.Logoff
Set objSession = Nothing
End Sub
 
Joined
Jul 11, 2005
Messages
3
Reaction score
0
Thanks

I saved this as a .vbs and ran it. My infostore is item(2) because for some reason the Archive.pst listed first in my Outlook profile. I successfully run down the folders and hit on the hidden collections, but the location doesn't change. I have tried locations that are network shares and locations that are local.

' MAPI property tags for aging properties
Public Const CdoPR_AGING_PERIOD = &H36EC0003
Public Const CdoPR_AGING_GRANULARITY = &H36EE0003
Public Const CdoPR_AGING_PATH = &H6856001E
Public Const CdoPR_AGING_ENABLED = &H6857000B

' Properties for aging granularity
Public Const AG_MONTHS = 0
Public Const AG_WEEKS = 1
Public Const AG_DAYS = 2

Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", True ,False



Set objInfoStore = objSession.InfoStores.Item(2)
Set objRootFolder = objInfoStore.RootFolder
Set colFolders = objRootFolder.Folders

Set objFolCalendar = objSession.GetDefaultFolder(CdoDefaultFolderCalendar)
Set objFolContacts = objSession.GetDefaultFolder(CdoDefaultFolderContacts)
Set objFolDeleted =objSession.GetDefaultFolder(CdoDefaultFolderDeletedItems)
Set objFolJournal = objSession.GetDefaultFolder(CdoDefaultFolderJournal)
Set objFolNotes = objSession.GetDefaultFolder(CdoDefaultFolderNotes)
Set objFolSent = objSession.GetDefaultFolder(CdoDefaultFolderSentItems)
Set objFolTasks = objSession.GetDefaultFolder(CdoDefaultFolderTasks)
Set objFolInbox = objSession.GetDefaultFolder(CdoDefaultFolderInbox)
Set objFolOutbox = objSession.GetDefaultFolder(CdoDefaultFolderOutbox)

For Each objFolder In colFolders
'msgbox "here"
' Get hidden message collection
Set objHiddenMessages = objFolder.HiddenMessages


' Loop through the hidden messages collection
For Each objMessage In objHiddenMessages
'msgbox "here2"

' Check if the message class points to an aging message
If objMessage.Type = "IPC.MS.Outlook.AgingProperties" Then

' Change aging properties to 14 months/weeks/days
objMessage.Fields.Item(CdoPR_AGING_PERIOD).Value = 22

' Change aging granularity to days
objMessage.Fields.Item(CdoPR_AGING_GRANULARITY).Value = AG_DAYS

' Change the path to the archive file
objMessage.Fields.Item(CdoPR_AGING_PATH).Value = "c:\archive.pst"

' Enable aging for this folder
objMessage.Fields.Item(CdoPR_AGING_ENABLED).Value = True

' Update hidden message
objMessage.Update True, True
End If
Next
Next
 
G

Guest

Okay, I see the problem now too. Indeed, even changes to the path in the UI
are not read by the code, even after a reboot. Same goes with changing the
path with the code - it is never reflected in the UI after a reboot. Indeed,
days have gone by and the path I've set in the code is never shown in the UI,
but the code STILL shows the value I've set in the code.

I thought this might be an issue with Cached mode, but this is really
irrelevant with .pst files, and it occurs with this off or on.

I'm stumped. I was! After I wrote that, I dug around some more. This same
issues was discussed in April:

http://groups-beta.google.com/group...="0x6859"+aging&rnum=1&hl=en#a07894c1baf4f9f0

Basically, Outlook 2003 stores this setting in a new MAPI property. Set a
MAPI.Field object reference using this constant:

Const CdoPR_AGING_PATH_V2 = &H6859001E '0x6859001E

Now you should be able to read and write it properly. Note the changes to
the other properties as per that thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top