Script to enable autoarchive on outlook 2003

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I will like to know how can I enable the autoarchive option of a folder's
properties in outlook 2003 with a visual basic script.

Any help would be really appreciated.

Regards.
 
Hi Ken,

Thank you for answering so fast.

I have a VB macro that is woking on outlook 2007 enabling Inbox autoarchive
property:

Based on the following URL:
http://blogs.msdn.com/jmazner/archi...es-on-a-folder-hierarchy-in-outlook-2007.aspx

-------------------------------------------------------------------------------------------------
Dim Period 'As Integer
Dim Granularity 'As Integer
Dim FileName 'As String
Dim AgeFolder 'As Boolean
Dim DeleteItems 'As Boolean
Dim Default 'As Integer

Const olFolderInbox = 6

Const strProptagURL As String = "http://schemas.microsoft.com/mapi/proptag/0x"

'------------------------------------------------------------------------------
'
' String values for the Exchange properties that govern aging / archiving
'
'------------------------------------------------------------------------------
Const strPR_AGING_AGE_FOLDER As String = strProptagURL + "6857000B"
Const strPR_AGING_PERIOD As String = strProptagURL + "36EC0003"
Const strPR_AGING_GRANULARITY As String = strProptagURL + "36EE0003"
Const strPR_AGING_DELETE_ITEMS As String = strProptagURL + "6855000B"
Const strPR_AGING_FILE_NAME_AFTER9 As String = strProptagURL + "6859001E"
Const strPR_AGING_DEFAULT As String = strProptagURL + "685E0003"
'Public Const strPR_AGING_FILE_NAME9_AND_PREV As String = strProptagURL +
"6856001E"
'Public Const strPR_AGING_DONT_AGE_ME As String = strProptagURL + "6858000B"
'Public Const strPR_AGING_WHEN_DELETED_ON_SERVER As String = strProptagURL +
"685B000B"
'Public Const strPR_AGING_WAIT_UNTIL_EXPIRED As String = strProptagURL +
"685C000B"
'Public Const strPR_AGING_VERSION As String = strProptagURL + "685D0003"

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set oFolder = objNamespace.GetDefaultFolder(olFolderInbox)

Period = 1 '
Granularity = 0 '0=Months, 1=weeks, 2=Days
FileName = "c:\pst" 'archive PST path
AgeFolder = True 'turns autoarchive on or off
DeleteItems = False 'Permanently delete old items

Dim oStorage As StorageItem
Dim oPA As PropertyAccessor

Debug.Print "Updating " + oFolder.Name

'Create or get solution storage in given folder by message class
Set oStorage = oFolder.GetStorage( _
"IPC.MS.Outlook.AgingProperties", olIdentifyByMessageClass)
Set oPA = oStorage.PropertyAccessor

If Not (AgeFolder) Then
oPA.SetProperty strPR_AGING_AGE_FOLDER, False
Else
'Set the 5 aging properties in the solution storage
oPA.SetProperty strPR_AGING_AGE_FOLDER, True
End If
oPA.SetProperty strPR_AGING_DEFAULT, 3 '3 Indicates default values

'Save changes as hidden messages to the associated portion of the folder
oStorage.Save

-------------------------------------------------------------------------------------------------


I have tested this macro with outlook 2003 but I receive an error from the
VB Compiler about this following two lines that are not supported:

Dim oStorage As StorageItem
Dim oPA As PropertyAccessor

So the question is, do you know if there is an equivalent of these two lines
on outlook 2003? or as you said we should be using a library like CDO? and..
if this is the case, is there an example of how to enable autoarchive using
CDO.

Thanks' for your support!
 
PropertyAccessor and StoreageItem were both added to the Outlook object
model in Outlook 2007 so it's not surprising that they wouldn't compile on
an Outlook 2003 machine. Outlook 2003 and earlier do not expose the
properties you need to do what you want, so you must use an alternate API
such as CDO 1.21 or Redemption. That link I provided does have CDO examples
for setting archive properties, did you look at it?
 
Back
Top