Solved

script to delete all attachments Outlook saves in the Temp OLK folder when Outlook closes.

Posted on 2006-06-24
7
752 Views
Last Modified: 2012-06-21
I would like a script which deletes all the attachments Outlook leaves behind in the OLK folder.  I would like the script or macro to run everytime Outlook closes.

Thanks
0
Comment
Question by:kapara
  • 3
  • 2
7 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
Hi kapara,

This code put into the ThisOutlookSession module did the trick for me:


Option Explicit

Private Sub Application_Quit()

    Dim TestPath As String
    Dim dic As Object
   
    Const TheFolder As String = "c:\Documents and Settings\username\Local Settings\Temporary Internet Files\OLKB0\"
   
    On Error Resume Next
   
    Set dic = CreateObject("Scripting.Dictionary")
   
    Do
        TestPath = Dir(TheFolder & "*.*")
        If TestPath <> "" And Not dic.Exists(TestPath) Then Kill TheFolder & TestPath
        If Err <> 0 Then
            dic.Add TestPath, TestPath
            Err.Clear
            MsgBox "Could not delete " & TestPath
        End If
    Loop Until TestPath = ""
   
    Set dic = Nothing
   
End Sub


Regards,

Patrick
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
This is a duplicate question.  kapara, you asked this same question several days ago in the Outlook area.
0
 
LVL 1

Author Comment

by:kapara
Comment Utility
Looking to do this automatically to all users who log in.  I hit submit before addidng that last bit.

Thanks
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 76

Accepted Solution

by:
David Lee earned 20 total points
Comment Utility
If you don't want to run the code from inside Outlook (e.g. as part of the shutdown process), then you could put the code I posted in the other question in a VBscript file and run it from a login or logout script.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
David,

Sorry, I did not see the previous question, so I figured it was a new one :)

Regards,

Patrick
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
Hi, Patrick.

No problem.  Hope all is well with you.

-- David
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now