Moving a Message to Another Folder

Moving a Message to Another Folder

The procedure documented in this section demonstrates, first, the old way to move message properties using the Messages collection’s Add method and the Message object’s Delete method, and then how to take advantage of the newer MoveTo method of the Message object.

Note   With CDO Library version 1.0, the Message object’s Sender property and other read-only properties of the Message object were not preserved during the first part of the procedure in this section. To preserve these properties using the old procedure, you had to append their text fields to read/write properties, such as the Message object’s Text property.

With the MoveTo method, every property that is set on a Message object is automatically moved to the new Message object, regardless of whether it has read-only or read/write access. The access of every property is also preserved across the copy.

ms527439.787845a5-a0eb-4ef0-a02b-af44a9f76e33(en-us,EXCHG.10).gif

To move a message from one folder to another

  1. Obtain the source message that you want to move.
  2. Call the destination folder’s Messages collection’s Add method, supplying the source message properties as parameters. – Or –
  3. Call the source Message object’s MoveTo method.
  4. Call the new Message object’s Update method to save all new information in the MAPI system.
  5. (Only necessary if you used the old Add and copy procedure) Call the source message’s Delete method to delete the original message from its folder.

For more details on this procedure and a sample code fragment, see Copying a Message to Another Folder. The comment lines at the end of the first copy procedure contain the call to delete the original message:

' If MOVING a message to another folder, delete the original message:
objThisMsg.Delete
' Move operation implies that the original message is removed
 

This Delete call is not necessary if the MoveTo method is used.

See Also

Concepts

Programming Tasks