tswaters
Computer
- Dec 7, 2005
- 1
I'm encountering some strange behaviour when using the MoveTo function...
here's the code:
Dim objSession As MAPI.Session
Dim objInbox As MAPI.Folder
Dim objMessages As Messages
Dim objMessage As Message
Dim objFolder As MAPI.folder
Set objSession = New MAPI.Session
objSession.Logon ProfileName:="profileName", NewSession:=True, showDialog:=False
Set objInbox = objSession.Inbox
Set objMessages = objInbox.Messages
Set objMessage = objMessages.GetFirst
Do While Not objMessage Is Nothing
If objMessage.Subject = "Certain Subject" And objMessage.Unread = True Then
objMessage.Unread = False
objMessage.Update
Set objFolder = objSession.InfoStores("DifferentDataFile").RootFolder.Folders("FolderWithinDataFile")
objMessage.MoveTo objFolder.FolderID, objFolder.StoreID
Set objMessage.GetNext
Loop
Ideally this should take certain unread messages with a given subject and mark them unread and move them to a folder within a different data file.
Most of it works. The weird thing is it moves it to the Data file's root folder instead of the "FolderWithinDataFile"....
Even stranger, if I set the MoveTo parameters to the RootFoler.FolderID & StoreID, the message dissapears!
Any help would be greatly appreciated.
Thanks
-Tyler