Hello,
I am using Outlook 2007 and really understand Excel VB, however, my Outlook VB capability is as a novice.
I have a VBA macro that moves email messages to a folder called rb Auto Deletes positioned as shown below:
After hours of searching and trying different approaches I have written this code which will permanently delete messages without going through the Outbox:
Sub AutoPermDelete()
' Usage: program mimics the entry of Shift + Delete to permanently delete an email
' How to use: select the mail item, execute this macro
Dim myOlApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim Sel As Selection
Set myOlApp = Outlook.Application
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set Sel = Application.ActiveExplorer.Selection
SendKeys ("+{DELETE}")
SendKeys ("{ENTER}")
End Sub
The code works perfectly but I have to select each email. So what I would like to have help with expanding the code to do the following:
1. 'Look' at the rb Auto Deletes folder.
2. Determine which messages are older than 1 calendar year from the current date and permanently delete them using my code.
I am totally lost as to how to make this happen and all my attempts have not worked so I am asking for help.
Merry Christmas and Thanks in Advance for your help!
I am using Outlook 2007 and really understand Excel VB, however, my Outlook VB capability is as a novice.
I have a VBA macro that moves email messages to a folder called rb Auto Deletes positioned as shown below:
After hours of searching and trying different approaches I have written this code which will permanently delete messages without going through the Outbox:
Sub AutoPermDelete()
' Usage: program mimics the entry of Shift + Delete to permanently delete an email
' How to use: select the mail item, execute this macro
Dim myOlApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim Sel As Selection
Set myOlApp = Outlook.Application
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set Sel = Application.ActiveExplorer.Selection
SendKeys ("+{DELETE}")
SendKeys ("{ENTER}")
End Sub
The code works perfectly but I have to select each email. So what I would like to have help with expanding the code to do the following:
1. 'Look' at the rb Auto Deletes folder.
2. Determine which messages are older than 1 calendar year from the current date and permanently delete them using my code.
I am totally lost as to how to make this happen and all my attempts have not worked so I am asking for help.
Merry Christmas and Thanks in Advance for your help!