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

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
LVL 1
kaparaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
David LeeConnect With a Mentor Commented:
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
 
Patrick MatthewsCommented:
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
 
David LeeCommented:
This is a duplicate question.  kapara, you asked this same question several days ago in the Outlook area.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
kaparaAuthor Commented:
Looking to do this automatically to all users who log in.  I hit submit before addidng that last bit.

Thanks
0
 
Patrick MatthewsCommented:
David,

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

Regards,

Patrick
0
 
David LeeCommented:
Hi, Patrick.

No problem.  Hope all is well with you.

-- David
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.