PDA

View Full Version : Outlook Macro, Move Selected Message to Inbox



Hopest
01-10-2012, 10:06 AM
Hi,

I am trying to create a macro button that when you press the button it will move the selected message to the inbox.

I have pasted code below but I am stuck on the "Msg.Move NamSpace.Folders = objNS.GetDefaultFolder(olFolderInbox)" which is the moving the message selected to the inbox.

If anyone has any better code which does what I want it to then please help me :)

Sub MoveItems()

Dim Messages As Selection
Dim Msg As MailItem
Dim NamSpace As NameSpace
Dim Proceed As VbMsgBoxResult


Set NamSpace = Application.GetNamespace("MAPI")
Set Messages = ActiveExplorer.Selection


If Messages.Count = 0 Then
Proceed = MsgBox("Please select a message!", vbOKOnly)
Exit Sub
End If

If Messages.Count = 1 Then
Proceed = MsgBox("Are you sure you want to move message?", vbYesNo)

If Proceed = vbNo Then
Exit Sub
Else
Msg.Move NamSpace.Folders = objNS.GetDefaultFolder(olFolderInbox)
End If
End If
End Sub

Sebastian H
01-13-2012, 04:21 PM
There shouldn't be an "=" sign in the Msg.Move line. Check out the MS VB Help by selecting the word "Move" and hitting the F1 key for a nice example.