Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Help !!! new to VB Scripting....

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3302
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Help !!! new to VB Scripting....
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Help !!! new to VB Scripting.... - 6/9/2005 2:14:20 AM   
  big10uk

 

Posts: 2
Score: 0
Joined: 6/9/2005
From: United Kingdom
Status: offline
Hi,

What I am trying to Achieve is the following:

I want to run a scipt that will open Outlook 2002 and delete all the items in the "Deleted Items" folder, when outlook is closed.

I have managed to do the macro in Outlook with deletes the emails, but am stuck with trying to run this from the desktop.

The vbs script i am using is below:
____________________________________________________

Public Sub EmptyJunkEmailFolder()

Dim outApp As Outlook.Application
Dim junkFolder As Outlook.MAPIFolder
Dim junkItem, deleteItem As Object
Dim entryID As String

Set outApp = CreateObject("outlook.application")
Set junkFolder = outApp.GetNamespace("MAPI").GetDefaultFolder(olFolderDeletedItems)

For Each junkItem In junkFolder.Items
junkItem.Delete
Next

Set junkItem = Nothing
Set deleteItem = Nothing
Set junkFolder = Nothing
Set outApp = Nothing

End Sub
____________________________________________________


When I cut a paste that into notepad and save it as .vbs, then run it, I get the following error.

Windows Script Host
-------------------
Scirpt: c:\test.vbs
Line: 3
Char: 16
Error: Expected end of statement
Code: 800A0401
Source: Microsoft VBScript compilation error


Any help would be much appreciated


Thanks

James
 
 
Post #: 1
 
 Re: Help !!! new to VB Scripting.... - 6/9/2005 4:11:52 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Sub EmptyJunkEmailFolder()

Dim outApp, junkFolder, junkItem, entryID

Set outApp = CreateObject("outlook.application")
Set junkFolder = outApp.GetNamespace("MAPI").GetDefaultFolder(olFolderDeletedItems)

For Each junkItem In junkFolder.Items
junkItem.Delete
Next

Set junkItem = Nothing
Set deleteItem = Nothing
Set junkFolder = Nothing
Set outApp = Nothing

End Sub

(in reply to big10uk)
 
 
Post #: 2
 
 Re: Help !!! new to VB Scripting.... - 6/9/2005 4:14:30 AM   
  royb5000

 

Posts: 54
Score: 0
Joined: 5/4/2005
From: USA
Status: offline
Just curious, I know in outlook 2003 there is an option to clear the deleted items folder when you close it, is that not an option in 2002?

(in reply to big10uk)
 
 
Post #: 3
 
 Re: Help !!! new to VB Scripting.... - 6/12/2005 8:52:06 PM   
  big10uk

 

Posts: 2
Score: 0
Joined: 6/9/2005
From: United Kingdom
Status: offline
Thanks Tnoonan,

I managed to get this to work:


Sub EraseDeletedItems()

Set outapp = CreateObject("Outlook.Application")
Set myNamespace = outapp.GetNamespace("MAPI")
Set Junkfolder = myNamespace.GetDefaultFolder(3)

For each JunkItem In Junkfolder.Items
JunkItem.Delete
Next

End Sub

EraseDeletedItems



Royb5000, I do have the option in OL2002 for that option, but the mailbox I am looking at can't be left open.

(in reply to big10uk)
 
 
Post #: 4
 
 Re: Help !!! new to VB Scripting.... - 6/13/2005 12:44:07 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
welcome

(in reply to big10uk)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Help !!! new to VB Scripting.... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts