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
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