INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VBA Visual Basic for Applications (Microsoft) FAQ

VBA How To

Set "do not autoarchive" in Outlook progmmatically by redapples
Posted: 28 Apr 04

Rarely used I would suggest but I found it useful for Journal Items for a particular project I was working on.  I started with a need to find out how much time I was spending on a particular project for billing purposes.  To do this I had set Access documents to be recorded automatically but soon found that I had to wade through tons of irrelivant items to get the items I needed.  

I then set about a quick function to add the items I need to an Access table and produce a report based on this table.
I wanted to reduce the clutter and thought autoarchiving would help.

the actual procedure for interigating the Mail box and setting the "do not AutoArchive" appears below.  Not sure if it will ever be used by anyone ever (which might explain the lack of documentation on the NoAging Property) but here it is none the less

CODE


Private Sub Command0_Click()
    'Outlook objects
    Dim objOL As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objContactFolder As Outlook.MAPIFolder
    Dim objItems As Outlook.Items
    Dim obj As Object
    
    'ADO objects
    Dim cnn As ADODB.Connection
    Dim rs As New ADODB.Recordset
    
    Dim strFilter
    
    'Set Outlook items
    Set objOL = CreateObject("Outlook.Application")
    Set objNS = objOL.GetNamespace("MAPI")
    Set objContactFolder = objNS.GetDefaultFolder(11)
    Set objItems = objContactFolder.Items
    
    'Set connection
    Set cnn = CurrentProject.Connection
    
    'clear previous records
    DoCmd.SetWarnings False
    DoCmd.RunSQL "Delete * From table1"
    DoCmd.SetWarnings True
    
    'set string to relevant folder where items generating _
     Journal items reside
    strFilter = "M:\Net_RSI\MONITORING\Aberdeen Cyrenians"
    
    'open rs
    rs.Open "Table1", cnn, 3, 3
    
    For Each obj In objItems
        If Left(obj.Subject, Len(strFilter)) = strFilter Then
            obj.NoAging = True ' set do not auto archive
            obj.Save ' save
            
            'Populate table
            With rs
            .AddNew
            !JeDate = obj.Start
            !JeDuration = obj.Duration
            !JeSubject = obj.Subject
            .Update
            .Requery
            End With
            
        End If
    Next obj

End Sub

provided me a valuable lesson in using the Object browser effectivly if nothing else

Back to VBA Visual Basic for Applications (Microsoft) FAQ Index
Back to VBA Visual Basic for Applications (Microsoft) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close