Hi folks. I hope someone can give me a little kickstart with my latest need. I simply want to write a macro that I can use to move a specific message (ostensibly, whatever one is currently selected in my In box) to a folder in PST file stored on my hard-drive. At this point, I must explain that this is for my work machine, which means that my mail messages are (normally) stored on the Exchange server. I mention that because it seemed that a lot of the code I found only handled moving things to a sub-folder. I tried some other code I found elsewhere, but it appears to expect one of Outlook’s “standard” folders, i.e. InBox, Calendar, etc. I don’t know how to direct the code to a seperate PST file/folder.
Here is the code I tried to use, along with a screen-cap to illustrate the “folder structure” I’m working with.
Sub MoveEmail()
Dim myItem As Outlook.MailItem, MyFolder As Outlook.MAPIFolder, olNS As NameSpace
On Error Resume Next
Select Case TypeName(Application.ActiveWindow)
Case “Explorer”
Set myItem = ActiveExplorer.Selection.Item(1)
Case “Inspector”
Set myItem = ActiveInspector.CurrentItem
Case Else
End Select
On Error GoTo 0
If myItem Is Nothing Then
MsgBox “Could not use current item. Please select or open a single email.”, vbInformation
Exit Sub
End If
Set olNS = Application.GetNamespace(“MAPI”)
Set MyFolder = olNS.GetDefaultFolder(olFolderInbox).Folders(“Receipts”)
myItem.Move MyFolder
End Sub
Any help would be greatly appreciated.