Macro to empty junk mail folder

D

Diane Poremsky [MVP]

How about...
R-click on the folder
Properties
Set AutoArchive to x days.
tools, options, other
enable autoarchive, run it every xx days

--
Diane Poremsky [MVP - Outlook]





EMO - a weekly newsletter about Outlook and Exchange:
(e-mail address removed)

You can access this newsgroup by visiting
http://www.microsoft.com/office/community/en-us/default.mspx or point your
newsreader to msnews.microsoft.com.
 
A

andrew-k

Thanks, Diane, but I want to create a macro that I can assign to a toolbar
button. The macro would delete the junk-mail folder contents whenever I want
to.
--
Best,
Andrew-K


Diane Poremsky said:
How about...
R-click on the folder
Properties
Set AutoArchive to x days.
tools, options, other
enable autoarchive, run it every xx days

--
Diane Poremsky [MVP - Outlook]





EMO - a weekly newsletter about Outlook and Exchange:
(e-mail address removed)

You can access this newsgroup by visiting
http://www.microsoft.com/office/community/en-us/default.mspx or point your
newsreader to msnews.microsoft.com.
 
D

Diane Poremsky [MVP]

pay a visit to outlookcode.com and learn how to write code in outlook.

--
Diane Poremsky [MVP - Outlook]





EMO - a weekly newsletter about Outlook and Exchange:
(e-mail address removed)

You can access this newsgroup by visiting
http://www.microsoft.com/office/community/en-us/default.mspx or point your
newsreader to msnews.microsoft.com.


andrew-k said:
Thanks, Diane, but I want to create a macro that I can assign to a toolbar
button. The macro would delete the junk-mail folder contents whenever I
want
to.
--
Best,
Andrew-K


Diane Poremsky said:
How about...
R-click on the folder
Properties
Set AutoArchive to x days.
tools, options, other
enable autoarchive, run it every xx days

--
Diane Poremsky [MVP - Outlook]





EMO - a weekly newsletter about Outlook and Exchange:
(e-mail address removed)

You can access this newsgroup by visiting
http://www.microsoft.com/office/community/en-us/default.mspx or point
your
newsreader to msnews.microsoft.com.


andrew-k said:
Can anyone show me the code for a macro that empties the junk mail
folder?
 
M

Michael Bauer [MVP - Outlook]

B

Brian Tillman [MVP - Outlook]

Thanks, Diane, but I want to create a macro that I can assign to a toolbar
button. The macro would delete the junk-mail folder contents whenever I
want
to.

How does this differ in any significant way from right-click>Empty?
 
M

Michael Bauer [MVP - Outlook]

In my opinion: Not at all. It only makes sense if you actually don't write
the macro yourself but get it written for free.

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Fri, 5 Sep 2008 13:59:48 -0400 schrieb Brian Tillman [MVP - Outlook]:
 
P

pcparadigm

This works for me:

Public Sub DeleteJunkMail()
Dim myFolder As Outlook.MAPIFolder
Dim myItems As Outlook.Items
Dim i As Long
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderJunk)
Set myItems = myFolder.Items

For i = myItems.Count To 1 Step -1
myItems.Remove i
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top