Okay, let's streamline the procedure to handle some errors that I suspect may
be occurring. The code doesn't care where on your file system the .pst is
stored - as long as it's loaded in Outlook and you know the display name, it
can be worked with using the Outlook Object Model.
Sub CustomMailMessageRule(Item As Outlook.MailItem)
On Error GoTo CustomMailMessageRule_Error
Dim myNameSpace As Outlook.NameSpace
Dim myPST As Outlook.MAPIFolder
Dim myFolder As Outlook.MAPIFolder
Set myNameSpace = Application.GetNamespace("MAPI")
Set myPST = myNameSpace.Folders("Personal Folders")
If myPST Is Nothing Then
MsgBox "The 'Personal Folders' folder cannot be located!!"
Exit Sub
End If
Set myFolder = myPST.Folders("0 Emails to file away")
If myFolder Is Nothing Then
MsgBox "The '0 Emails to file away' folder cannot be located!!"
Exit Sub
End If
Item.FlagStatus = olFlagMarked
Item.Subject = Item.Subject & " ( " & Now() & " ) "
Item.Save
Item.Move myFolder
On Error GoTo 0
Exit Sub
CustomMailMessageRule_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
CustomMailMessageRule of VBA Document ThisOutlookSession"
Resume Next
End Sub
Ok, it looks like I can't run any other action with the script. So I
modified it so that it will also flag the message, date it, and then move it.
[quoted text clipped - 29 lines]