Macro changes ReceivedTime when it shouldn't

  • Thread starter Thread starter Galen Murdock
  • Start date Start date
G

Galen Murdock

Hello --

History: I've got a macro to move selected emails to another folder. It's
been working fine in Outlook for a long time (local .pst's, remote POP3/SMTP
servers). We recently installed Exchange 2007, and I created a new,
Exchange-based profile and imported my old macros. I use this macro for
personal productivity -- to quickly move selected items out of the inbox into
a history folder.

Question/Problem: Now that I'm running against Exchange, the macro changes
the received date/time of the item to the current date/time. So I can't use
my macro without it actually changing the receive dates of the emails I use
it on. To be more specific, in the code below, the "Check 2:" line always
shows the date/time on which the line above it was executed, not the original
received time. Anyone know how to move an item programmatically without
changing anything about the item?

Code:

Public Sub MoveSelectedEmailsToAllFolder_Exchange3()
On Error GoTo HError

Const DEST_FOLDER_ROOT As String = "Cache"
Const ALL_FOLDER As String = "All"

Dim myDestFolder As Folder
Set myDestFolder =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders(DEST_FOLDER_ROOT).Folders(ALL_FOLDER)

Dim strDebug As String
strDebug = vbNullString

Dim lCount As Long
lCount = 0

Dim curItm As Object
Dim newItm As Object
For Each curItm In Application.ActiveExplorer.Selection
MsgBox "Check 1: curItm.ReceivedTime=" & Format(curItm.ReceivedTime)
Set newItm = curItm.Move(myDestFolder)
MsgBox "Check 2: newItm.ReceivedTime=" & Format(newItm.ReceivedTime)
lCount = lCount + 1
Next

' for debug only
' MsgBox "Moved " & lCount & " items."

GoTo HExit
HError:

MsgBox "ERROR " & Err.Number & " in " & Err.Source & ": " &
Err.Description & vbCrLf & vbCrLf & "Debug Info:" & vbCrLf & strDebug
Resume HExit
HExit:
Set newItm = Nothing
Set curItm = Nothing
Set myDestFolder = Nothing
End Sub

TIA!

-- Galen
________________
Galen Earl Murdock
Veracity Solutions
 
This is an OOM bug (or feature): RecievedTime time changes when you move
messages between stores or when you modify them and call Save.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Hmm, but I'm not moving it between stores -- just trying to move it to the
child of a peer folder. How do I move it programmatically without causing
the framework to think it's been changed? Supposing this to be an issue,
I've already tried all kinds of ways of referencing the folder, such as:

* starting from ThisOutlookSession.ActiveExplorer.CurrentFolder
* starting from Application (example in the code below)
* starting from
ThisOutlookSession.Session.Stores.Item(pstNameContainingMainInbox).GetRootFolder
* starting from
GetNamespace("MAPI").Stores.Item(pstNameContainingMainInbox).GetRootFolder

etc.

Bug? Feature? Heh...

Thanks!
Galen

__________________
Galen Earl Murdock
Veracity Solutions
 
You can't this is just what Outlook Object Model does.
Extended MAPI (and Redemption) do not have this bug.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Back
Top