K
Keith
I know this question hass been asked before but I was unable to make it work.
In order to make up for Outlook's inadequate handling of IMAP, I put
together a simple macro that would move messages to a folder "Trash" when
invoked. (The delete key deletes emails forever - thank you Microsoft!)
All I want to do is to enable the macro without having to manually enable it
each time I start outlook and without setting my security settings to enable
all macros.
I would appreciate any help.
Here is the code:
Sub MoveToTrash()
On Error Resume Next
Dim objFolder As MAPIFolder
Dim objNS As NameSpace, objItem As MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.Folders("KJB").Folders("Trash")
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.UnRead = False
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
End Sub
In order to make up for Outlook's inadequate handling of IMAP, I put
together a simple macro that would move messages to a folder "Trash" when
invoked. (The delete key deletes emails forever - thank you Microsoft!)
All I want to do is to enable the macro without having to manually enable it
each time I start outlook and without setting my security settings to enable
all macros.
I would appreciate any help.
Here is the code:
Sub MoveToTrash()
On Error Resume Next
Dim objFolder As MAPIFolder
Dim objNS As NameSpace, objItem As MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.Folders("KJB").Folders("Trash")
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.UnRead = False
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
End Sub