rules
RH

Forum home » Delegate support and help forum » Microsoft Outlook Training and help » Rules

Rules

resolvedResolved · Urgent Priority · Version 2003

Liz has attended:
SharePoint course

Rules

Hello
I want to set a rule to delete all sent mail and all deleted mail after 8 hours. I have tried to do so without success. Please send idiot's step by step guide.
Could such a rule be established centrally, or would each user in our office need to do that on their own machine.
thanks

RE: rules

Hi Liz,

I don't think there is a way to do this with Rules, as Rules is more about controlling which folder your mail is delivered to.

I have found and edited some VBA code which seems to work for me.

You have specified in your post that you are using Outlook 2003, and I have tested this code in Outlook 2003. If you are using a different version of Outlook, it may not work.

I haven't figured out how to do this every 8 hours yet, so for now you will just have to press a toolbar button at the end of each day.

Idiot's step by step guide:


1) In outlook, go to Tools -> Macro -> Visual Basic Editor
2) Copy and paste this VBA code into the window that appears:

Public Sub EmptyDeletedJunkEmailFolder()

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

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

For Each junkItem In junkFolder.Items
entryID = junkItem.entryID ' Store item entry id
junkItem.Delete ' Delete from junk mail folder

' To permanently delete item find and delete from deleted items
Set deleteItem = outApp.Session.GetItemFromID(entryID)
deleteItem.Delete
Next

For Each diItem In diFolder.Items
entryID = diItem.entryID ' Store item entry id
diItem.Delete ' Delete from deleted item folder

Next

Set junkItem = Nothing
Set diItem = Nothing
Set deleteItem = Nothing
Set junkFolder = Nothing
Set diFolder = Nothing
Set outApp = Nothing

End Sub


3) Go to File -> Save or Control+S on keyboard (note: it may say 'Save VBAProject.otm') You can now close the VBA editor window to return to Outlook.

4) You now have a macro that you can run. You can do this a number of ways, the most common way is to go to Tools -> Macro -> Macros, selecting the sub-routine we just created (EmptyDeletedJunkEmailFolder) and pressing the 'Run' button.

5) As your macro deletes all the appropriate items, you should see the hour-glass mouse cursor and you may not be able to use Outlook until it finishes.

6) To make it easier for you to run the macro (perhaps at the end of each day, or start of each day), you can add a button to one of your toolbars which runs the Macro.

To do this, go to Tools -> Customize -> Commands tab, then scroll down the Categories list until you find and select 'Macros'.

Then, from the commands list on the right, click and drag your new macro to a toolbar of your choice.

The button may have a really long name, but you can rename this by right clicking the toolbar item and the third option is 'name' - you can delete the text there and rename it. Perhaps 'Clear deleted/junk' could be a good name?

To return to outlook, click the 'Close' button on the customize window. Then try out your new button.

I found that when I ran the macro, it only affected my main PST file (ie. where mail is normally delivered). It didn't have any effect on my additional PST files. If you're running exchange server, i'm not sure if it will work - get back to me if that's the case.

Let me know how you get on with this Liz. I'd like to help if you experience any trouble.

Regards, Rich

RE: rules

Hi Liz,

After starting my Outlook again this morning, I've noticed my macro doesn't work any more. This is because the Security settings for Macros is set to 'high' by default.

I needed to change the security level to 'medium' by going to Tools -> Macro -> Securty -> Security level tab -> 'Medium' option.

Then, when outlook started or I ran my macro, a warning message came up asking me if i wanted to enable macros for the VB script. I had to say 'enable macros' for the macro to work.

Regards, Rich

RE: rules

Thank you for this. However, if it still involves the user having to take action every day it seems rather over-elaborate. What we do now is just empty SENT and DELETED every day. We were looking for something which would automate this process.

Furthermore, I do believe we run an exchange server.
When I was investigating inside the rules area yesterday I occasionally came across a "delete" action. But not when dealing with all SENT etc.
Liz

RE: rules

Hi Liz,

Ahh, I see.

The solution to your query will take a bit longer to research, and possibly even consultancy, as this isn't a usual function of Outlook.

Let me see what I can come up with and I'll get back to you.

Regards, Rich

RE: rules

Hi Liz

Your requirement falls out of the ambit of this forum, as it will require dedicated time from one of our trainers to resolve. We offer this as a consulting service that we can either do at your site or remotely. Consultancy rates start from

RE: rules

Hi Liz

I will give you a call about your requirement.

One option might be to set AutoArchive on your mail folders so that for example the deleted items folder is cleared when auto archive runs.

Alternatively you can enforce retention policies on the server which overide the users's autoarchive settings. For example the Mailbox Manager on Exchange Server uses rules to manage the size of mailboxes by controlling the age of messages in specific folders.

Kind regards,
Andrew

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Outlook tip:

Clear Deleted Items Folder On Exit

To permanently remove all items in your Deleted Items folder on exit.

1. Click "Tools" and select "Options"
2. In the "Options" dialog box, click the "Other" tab
3. Check "Empty the Deleted Items folder upon exiting".
4. Click "OK" to close.

NOTE that after this is done ALL items that were in the folder will be gone forever and cannot be retrieved.

View all Outlook hints and tips


Server loaded in 0.05 secs.