Move an e-mail to Public folder or inbox subfolder

G

Guest

Hello everyone,

just wounder is it possible to write a macro to move an e-mail to a
subfolder in public folder ? I would like to have a button on the top of my
outlook 2003 so that when I click on that button, it will move a selected
e-mail to a subfolder in public folder. I am not a programmer, any help will
be really appreciated. thanks
 
G

Guest

Are you at least comfortable with working in the VBA Editor? You'll need
some experience there to construct the following:

- First select the Public Folder you want to move a message to and run this:

Sub GetEntryIDsForCurrentFolder()
Debug.Print "EntryID: " & Application.ActiveExplorer.CurrentFolder.EntryID
Debug.Print "StoreID: " & Application.ActiveExplorer.CurrentFolder.StoreID
End Sub

Then use those values for the const# variables in the procedure below:

Sub MoveSelectedMessageToConfiguredFolder()
On Error GoTo MoveToPublicFolder_Error

Dim objPF As Outlook.MAPIFolder
Dim constEntryID As String
Dim constStoreID As String
Dim objMsg As Object

If Application.ActiveExplorer.Selection Is Nothing Or
Application.ActiveExplorer.Selection.Count > 1 Then
MsgBox "Please select a single message to move.", vbOKOnly +
vbExclamation, "Invalid Selection"
Exit Sub
End If

constEntryID = "{YOUR FOLDER'S ENTRYID}"
constStoreID = "{YOUR FOLDER'S STOREID}"

Set objPF = Application.Session.GetFolderFromID(constEntryID,
constStoreID)
If objPF Is Nothing Then
MsgBox "Invalid folder.", vbOKOnly + vbExclamation
Exit Sub
End If

Set objMsg = Application.ActiveExplorer.Selection.item(1)
objMsg.Move objPF

On Error GoTo 0
Exit Sub

MoveToPublicFolder_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
MoveSelectedMessageToConfiguredFolder of VBA Document ThisOutlookSession"
Resume Next
End Sub

You can also map this macro to a custom button or run it manually.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top