K
Ken Grubb
I'm running Win XP and Office XP SP3.
When I start Outlook, PurgeIMAP runs and throws a "Run-time error '5';
Invalid procedure call or argument" on the line:
Set myPurge = myEdit.Controls("Purge Deleted Messages")
I suspect there's something simple I'm doing wrong.
Ken Grubb
Bellevue, WA, USA
**************************************
Option Explicit
Private Sub Application_Startup()
Call PurgeIMAP
End Sub
Public Sub PurgeIMAP()
Dim myApplication As Application
Dim myNameSpace As NameSpace
Dim myServer As Object
Dim myInbox As Outlook.MAPIFolder
Dim myEdit As Object
Dim myPurge As Object
Dim myReturnFolder As Outlook.MAPIFolder
Set myApplication = CreateObject("Outlook.Application")
Set myNameSpace = myApplication.GetNamespace("MAPI")
Set myServer = myNameSpace.Folders("kengrubb.deskmail.washington.edu")
Set myInbox = myServer.Folders("Inbox")
Set myReturnFolder = ActiveExplorer.CurrentFolder
Set ActiveExplorer.CurrentFolder = myInbox
Set myEdit = ActiveExplorer.CommandBars("Edit")
Set myPurge = myEdit.Controls("Purge Deleted Messages")
myPurge.Execute
Set ActiveExplorer.CurrentFolder = myReturnFolder
Set myPurge = Nothing
Set myEdit = Nothing
Set myReturnFolder = Nothing
Set myInbox = Nothing
Set myServer = Nothing
Set myNameSpace = Nothing
Set myApplication = Nothing
End Sub
When I start Outlook, PurgeIMAP runs and throws a "Run-time error '5';
Invalid procedure call or argument" on the line:
Set myPurge = myEdit.Controls("Purge Deleted Messages")
I suspect there's something simple I'm doing wrong.
Ken Grubb
Bellevue, WA, USA
**************************************
Option Explicit
Private Sub Application_Startup()
Call PurgeIMAP
End Sub
Public Sub PurgeIMAP()
Dim myApplication As Application
Dim myNameSpace As NameSpace
Dim myServer As Object
Dim myInbox As Outlook.MAPIFolder
Dim myEdit As Object
Dim myPurge As Object
Dim myReturnFolder As Outlook.MAPIFolder
Set myApplication = CreateObject("Outlook.Application")
Set myNameSpace = myApplication.GetNamespace("MAPI")
Set myServer = myNameSpace.Folders("kengrubb.deskmail.washington.edu")
Set myInbox = myServer.Folders("Inbox")
Set myReturnFolder = ActiveExplorer.CurrentFolder
Set ActiveExplorer.CurrentFolder = myInbox
Set myEdit = ActiveExplorer.CommandBars("Edit")
Set myPurge = myEdit.Controls("Purge Deleted Messages")
myPurge.Execute
Set ActiveExplorer.CurrentFolder = myReturnFolder
Set myPurge = Nothing
Set myEdit = Nothing
Set myReturnFolder = Nothing
Set myInbox = Nothing
Set myServer = Nothing
Set myNameSpace = Nothing
Set myApplication = Nothing
End Sub