Setting Folder Aging Properties Prob

E

Eric Legault [MVP - Outlook]

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
 
R

rbuckley

I saved this as a .vbs and ran it. My infostore is item(2) because fo
some reason the Archive.pst listed first in my Outlook profile.
successfully run down the folders and hit on the hidden collections
but the location doesn't change. I have tried locations that ar
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 objFolDelete
=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
Nex
 
E

Eric Legault [MVP - Outlook]

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.
 
G

Goku316

Please Everyone I have been watching your post all this wekend and I a
not a programmer just a simple sys admin...

I need your help on the topic at hand....

our company is short on $$$ but we too need to impliment auto archivin
and your CDO Code seems to be a way to help our company....


I see the posted codes you all have submitted but if it is working ca
some one explain to me how can i use this to do the same for m
company....

all help is welcomed...

Tony...

(e-mail address removed)
 
M

Merlin

Hello,

I know this thread has stopped for a while but I had been working for
this for a while, dropped and is working on it again out of interest.

Would appreciate it if anyone can input on this.

Does anybody know how to distinguish, in Outlook 2003, the difference in
settings between a folder with specific AutoArchive settings and 1 that
is using the "Archive items...using the default settings." option?

BTW, anybody knows of a source with more complete information on this
subject?

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
 

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