Solved

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

Posted on 2006-06-24
7
753 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
ID: 16976058
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
ID: 16976368
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
ID: 16976483
Looking to do this automatically to all users who log in.  I hit submit before addidng that last bit.

Thanks
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 76

Accepted Solution

by:
David Lee earned 20 total points
ID: 16976494
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
ID: 16976513
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
ID: 16976515
Hi, Patrick.

No problem.  Hope all is well with you.

-- David
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

932 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

14 Experts available now in Live!

Get 1:1 Help Now