Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Outlook move macro changes message date

Avatar of jtgerdes
jtgerdes asked on
Visual Basic ClassicOutlook
2 Comments1 Solution488 ViewsLast Modified:

I am trying to get a macro working in Outlook to move the selected message(s) to a specified folder.  I have found VB code that works, with the exception that moving a message to a folder changes the Received date/time to the current date/time upon moving the message.

I have done plenty of searching, but I have not found a solution yet.  I have read enough information to know that the Outlook Object Model has this bug when moving messages, but Extended MAPI does not.  How can this code be rewritten so that the date/time does not get changed?

I am using Outlook 2007, with Exchange 2007.  I only know enough VB to piece together code snippets to do what I want, and I've reached my limit with this issue.

Thank you!
Sub MoveVM()
On Error Resume Next
    Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
    Dim objNS As Outlook.NameSpace, objItem As Outlook.mailItem
    Set objNS = Application.GetNamespace("MAPI")
    Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
    Set objFolder = objInbox.Folders("Voicemail")
If objFolder Is Nothing Then
     MsgBox "Folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
End If
    If Application.ActiveExplorer.Selection.Count = 0 Then
        Exit Sub
    End If
    For Each objItem In Application.ActiveExplorer.Selection
        If objFolder.DefaultItemType = olMailItem Then
            If objItem.Class = olMail Then
                objItem.Move objFolder
            End If
        End If
    Set objItem = Nothing
    Set objFolder = Nothing
    Set objInbox = Nothing
    Set objNS = Nothing
End Sub
Avatar of David Lee
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers