Emptying Junk E-mail Folder
Moderators: JRL, Dorian (MJT support)
Emptying Junk E-mail Folder
Is there any (VBScript) trick to empty the Junk E-mail Folder in Outlook 2003?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Hi Armstrong....
Check out coding from Helen Feddema. Don't have access to my code/books right now, but just google her. See her Sample Code pages. I have used her code in many applications. Her code is VB/VBA but I think will be close enough to VBScript to be helpful. I have not checked her site for a few months/yrs?, but am sure her work is still available.
Can also get a book on Programming with Outlook98 from Amazon for under $5. Introductory, but provides references to most of the Objects that you need to navigate Outlook folders.
Check out coding from Helen Feddema. Don't have access to my code/books right now, but just google her. See her Sample Code pages. I have used her code in many applications. Her code is VB/VBA but I think will be close enough to VBScript to be helpful. I have not checked her site for a few months/yrs?, but am sure her work is still available.
Can also get a book on Programming with Outlook98 from Amazon for under $5. Introductory, but provides references to most of the Objects that you need to navigate Outlook folders.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Hi Bob,
My respectable MS Guru, it's my honor to meet you again here. Thanks for your tips. After receving your post hours ago, I googled around and found, of course, Helen Feddema's homepage (http://www.helenfeddema.com/). I didn't find something I want. Yes, it requires a lot of digging.
Even though emptying Junk E-mail can be done by MS script, I still opt for a VBA solution.
Thanks for your help.
My respectable MS Guru, it's my honor to meet you again here. Thanks for your tips. After receving your post hours ago, I googled around and found, of course, Helen Feddema's homepage (http://www.helenfeddema.com/). I didn't find something I want. Yes, it requires a lot of digging.
Even though emptying Junk E-mail can be done by MS script, I still opt for a VBA solution.
Thanks for your help.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Here you go:
VBSTART
Sub EmptyFolder(FolderName)
Dim Outlook
Dim PersonalFolder
Dim oFolder
Dim Item
Set Outlook = CreateObject("Outlook.Application")
Set PersonalFolder = Outlook.GetNamespace("MAPI").Folders("Personal Folders")
Set oFolder = PersonalFolder.Folders(FolderName)
Do Until oFolder.Items.Count = 0
Set Item = oFolder.Items.GetFirst
Item.Delete
Loop
Set Item = Nothing
Set oFolder = Nothing
Set PersonalFolder = Nothing
Set Outlook = Nothing
End Sub
VBEND
VBRun>EmptyFolder,Junk
Use to empty whichever folder you like - just put the folder name in the VBRun>EmptyFolder line. E.g. to empty your Outbox:
VBRun>EmptyFolder,Outbox
VBSTART
Sub EmptyFolder(FolderName)
Dim Outlook
Dim PersonalFolder
Dim oFolder
Dim Item
Set Outlook = CreateObject("Outlook.Application")
Set PersonalFolder = Outlook.GetNamespace("MAPI").Folders("Personal Folders")
Set oFolder = PersonalFolder.Folders(FolderName)
Do Until oFolder.Items.Count = 0
Set Item = oFolder.Items.GetFirst
Item.Delete
Loop
Set Item = Nothing
Set oFolder = Nothing
Set PersonalFolder = Nothing
Set Outlook = Nothing
End Sub
VBEND
VBRun>EmptyFolder,Junk
Use to empty whichever folder you like - just put the folder name in the VBRun>EmptyFolder line. E.g. to empty your Outbox:
VBRun>EmptyFolder,Outbox
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?