ReceivedTime changes when moving MailItem

L

lukor

Hi,
I am using simple macro to move completed Mails to specific folder (to
be able to run it from toolbar button) - in Outlook 2003. It works
great with a little annoynace. Everytime I move an item, it's
ReceivedTime changes to the current date and time, so I completely
loose track when the mail was originaly recieved! How can I avoid this?

Thanks a lot,
Lukas.

Sub MoveSelectedMessagesToFolder(destfolder As String)
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(destfolder)


For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
rcvtime = objItem.ReceivedTime

' here I move the MailItem
objItem.Move objFolder

End If
End If
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
 
G

Guest

It is impossible to programmatically change the value of the ReceivedTime
property as it is read-only. This value is set by the mail server when it
receives a message.

Are you witnessing this change by looking at the value for that item in a
folder with the Received field visible in the view?

Otherwise, the only odd thing I see in your code is that rcvtime is not
declared as a variable, and it should be if you have the Option Explicit
statement in your module.
 
L

lukor

Eric, thanks for you interrest. The rcvtime variable is in the code
only because of debugging. Sorry to confuse you, I should have removed
it from the sample.

Yes, I see the change in the Receved field in the current view.
Actually it is quite consfusing since when I use code like this:

MsgBox objItem.RecievedTime
objItem.Move objFolder
MsgBox objItem.RecievedTime

it displays the original (correct) date twise, which suggest that the
date does NOT change. Anyway, immediately after the macro ends, the
column Recieved shows the current date and time. I observe the same
behavior even when I use the method objItem.Copy.
What can be wrong?

Thanks again, Lukas
 

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