×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

CDO Folder moveTo function

CDO Folder moveTo function

CDO Folder moveTo function

(OP)

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources