MailItem.Move Method

Outlook Developer Reference

Moves a Microsoft Outlook item to a new folder.



expression   A variable that represents a MailItem object.


Name Required/Optional Data Type Description
DestFldr Required Folder An expression that returns a Folder object. The destination folder.

Return Value
An Object value that represents the item which has been moved to the designated folder.


This Visual Basic for Applications (VBA) example uses GetDefaultFolder to return the Folder object that represents the default folder. It then uses the Find and FindNext methods to find all messages sent by Dan Wilson and uses the Move method to move all e-mail messages sent by Dan Wilson from the default Inbox folder to the Personal Mail folder. To run this example without any errors, replace 'Dan Wilson' with a vaid sender name and make sure there's a folder under Inbox called 'Personal Mail'. Note that myItem is declared as type Object so that it can represent all types of Outlook items including meeting request and task request items.

Visual Basic for Applications
  Sub MoveItems()
    Dim myNameSpace As Outlook.NameSpace
    Dim myInbox As Outlook.Folder
    Dim myDestFolder As Outlook.Folder
    Dim myItems As Outlook.Items
    Dim myItem As Object
Set myNameSpace = Application.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
Set myDestFolder = myInbox.Folders("Personal Mail")
Set myItem = myItems.Find("[SenderName] = 'Dan Wilson'")
While TypeName(myItem) <> "Nothing"
    myItem.<strong>Move</strong> myDestFolder
    Set myItem = myItems.FindNext

End Sub

See Also