Scheduled task to empty Outlook deleted items 
Author Message
 Scheduled task to empty Outlook deleted items

As the subject says I'm looking for a way to empty the deleted items in
Outlook on a schedule.  I prefer a script in the .VBS fashion as I'm trying
to get some more hands-on experience with it.  I would also like to be able
to run it without Outlook being open/connected to the Exchange server.

Any suggestions/guidance is much appreciated!
THANKS!
Ken Chapin



Sat, 13 Aug 2005 22:39:22 GMT  
 Scheduled task to empty Outlook deleted items
Until someone who has the correct answer replies here is a script I was
playing with to delete certain items from my sent mail. You can try and
modify it to see if it does what you want it to do. :-)  You just have to
adjust the "to" items below to get this to work as is. :-)
I did get some errors with this script when it looped through and hit a
meeting confirmation

Option Explicit
Dim fso, wshshell
Set wshshell=WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
wshshell.AppActivate ("Microsoft Outlook")
' If wshshell.AppActivate ("Microsoft Outlook") Then
' else
' wshshell.run Chr(34)&"c:\Program Files\Microsoft
Office\Office10\OUTLOOK.EXE"&Chr(34)
' End if
WScript.Sleep 5000
Dim objOutlook
        Dim objNameSpace
        Dim objFolder
        Dim MyItems
        Dim CurrentAppointment
        Dim strOutput

        Const olMailItem = 0
        Const olTaskItem = 3
        Const olFolderTasks = 13
        Const olFolderSentItems = 5
Dim count, item,i,counter
count = 0
On Error Resume next
        'Create Outlook, Namespace, Folder Objects and Task Item
            Set objOutlook = createObject("Outlook.application")
            Set objNameSpace = objOutlook.GetNameSpace("MAPI")
            Set objFolder = objNameSpace.GetDefaultFolder(olFoldersentitems)
            'Set MyItems = objFolder.Items
            For i = 1 To  objFolder.items.count
            counter = counter +1
            If Err.Number <> 0 Then
            MsgBox Err.Number & Err.Description
            Err.Clear

            Else

            If objFolder.Items(i).to  = "'someone'" or objFolder.Items(i).to
= "'someone,else'" or objFolder.Items(i).to = "'another person'" or
objFolder.Items(i).to = "'yikes another one'" or objFolder.Items(i).to =
"Don't you keep anything" or objFolder.Items(i).to = "wow" or
objFolder.Items(i).to = "more"or  objFolder.Items(i).to = "about time" Then
            objFolder.Items(i).delete
            count = count + 1
            End If
            End If
            Next
            MsgBox "messages moved to deleted = " &count &" counter = "
&counter


Quote:
> As the subject says I'm looking for a way to empty the deleted items in
> Outlook on a schedule.  I prefer a script in the .VBS fashion as I'm
trying
> to get some more hands-on experience with it.  I would also like to be
able
> to run it without Outlook being open/connected to the Exchange server.

> Any suggestions/guidance is much appreciated!
> THANKS!
> Ken Chapin



Sun, 14 Aug 2005 03:08:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Scheduled task to empty Outlook deleted items

2. Emptying Outlook Deleted Items Folder.

3. wsh scheduled task versus sql scheduled tasks -performance issue

4. Scheduled Task to delete a folder at logon

5. Outlook Empy 'Deleted Items Folder'

6. Outlook -Deleted items

7. Outlook Empy 'Deleted Items Folder'

8. Setting Username and Passwords for a scheduled task in MS Task Scheduler

9. Setting Username and Passwords for a scheduled task in MS Task Scheduler

10. Scripting msdev in a scheduled task?

11. Scheduling vbs tasks

 

 
Powered by phpBB® Forum Software