Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 766
  • Last Modified:

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
0
kapara
Asked:
kapara
  • 3
  • 2
1 Solution
 
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
 
kaparaAuthor Commented:
Looking to do this automatically to all users who log in.  I hit submit before addidng that last bit.

Thanks
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
David LeeCommented:
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:
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now