I was hoping someone could help me understand how to move emails to a different PST file. Currently I have edited a script I found online which allows emails to be moved to various folders based on a macro which executes either from a button in the top menu bar area, or with shortcut keys. Right now it is all working excellent, but I want to take it a step further and have it function the same but also allow a button which will move emails to a separate PST file. This particular macro will be running in Outlook 2007.
I read this but I wasn't able to get it functioning based on the macro I have customized:
http://www.slipstick.com/developer/macro-move-aged-mail/
My current Macro is as follows:
-It allows emails to be moved to 3 different folder locations within the main PST "Inbox" folder.
MACRO:
----------------------------------- 'Outlook VB Macro to move selected mail item(s) to a target folder
Sub MoveToFolder(targetFolder)
On Error Resume Next
Dim ns As Outlook.NameSpace
Dim MoveToFolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Set ns = Application.GetNamespace("MAPI")
'define path to the target folder; the following assumes the target folder
'is a sub-folder of the main Mailbox folder
'This is the original'
'Set MoveToFolder = ns.Folders("Mailbox").Folders(targetFolder)'
Set MoveToFolder = ns.GetDefaultFolder(olFolderInbox).Folders(targetFolder)
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox ("No item selected")
Exit Sub
End If
If MoveToFolder Is Nothing Then
MsgBox "Target folder not found!", vbOKOnly + vbExclamation, "Move Macro Error"
End If
For Each objItem In Application.ActiveExplorer.Selection
If MoveToFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move MoveToFolder
End If
End If
Next
Set objItem = Nothing
Set MoveToFolder = Nothing
Set ns = Nothing
End Sub
Sub MoveToActive()
MoveToFolder ("Active")
End Sub
Sub MoveToAction()
MoveToFolder ("Action")
End Sub
Sub MoveToOnHold()
MoveToFolder ("OnHold")
End Sub
-----------------------------------Can someone help me configure it so a 4th option will move an email to a folder within a different PST?
For example I would like to add an extra button called "Archive", and when this particular button is clicked it will move the email to the archive folder within the separate PST's Inbox
Sub MoveToArchive()
MoveToFolder ("Archive")
End Sub
I read this but I wasn't able to get it functioning based on the macro I have customized:
http://www.slipstick.com/developer/macro-move-aged-mail/
My current Macro is as follows:
-It allows emails to be moved to 3 different folder locations within the main PST "Inbox" folder.
MACRO:
----------------------------------- 'Outlook VB Macro to move selected mail item(s) to a target folder
Sub MoveToFolder(targetFolder)
On Error Resume Next
Dim ns As Outlook.NameSpace
Dim MoveToFolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Set ns = Application.GetNamespace("MAPI")
'define path to the target folder; the following assumes the target folder
'is a sub-folder of the main Mailbox folder
'This is the original'
'Set MoveToFolder = ns.Folders("Mailbox").Folders(targetFolder)'
Set MoveToFolder = ns.GetDefaultFolder(olFolderInbox).Folders(targetFolder)
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox ("No item selected")
Exit Sub
End If
If MoveToFolder Is Nothing Then
MsgBox "Target folder not found!", vbOKOnly + vbExclamation, "Move Macro Error"
End If
For Each objItem In Application.ActiveExplorer.Selection
If MoveToFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move MoveToFolder
End If
End If
Next
Set objItem = Nothing
Set MoveToFolder = Nothing
Set ns = Nothing
End Sub
Sub MoveToActive()
MoveToFolder ("Active")
End Sub
Sub MoveToAction()
MoveToFolder ("Action")
End Sub
Sub MoveToOnHold()
MoveToFolder ("OnHold")
End Sub
-----------------------------------Can someone help me configure it so a 4th option will move an email to a folder within a different PST?
For example I would like to add an extra button called "Archive", and when this particular button is clicked it will move the email to the archive folder within the separate PST's Inbox
Sub MoveToArchive()
MoveToFolder ("Archive")
End Sub