O'Reilly logo

CDO & MAPI Programming with Visual Basic: by Dave Grundgeiger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Forwarding and Replying to Mail

Message objects contain methods that make forwarding and replying to email easy. The Forward method returns a new Message object that is a copy of the original, with a couple of exceptions. The Recipients collection and Text property of the message are not copied. The recipients aren’t copied because it is assumed that a forwarded message will be sent to a different set of recipients than was the original. The message text often should be modified as well, to indent or quote the original text, for example. The Microsoft documentation is careful to note that this behavior of the Text property is for the current implementation (CDO version 1.21), implying that this could change, so don’t rely on the Text property of the new message being empty.

Example 6-6 shows how the Text property might be handled on a forwarded message. The example shows a function, CreateForward, that takes a Message object, calls its Forward method to obtain another Message object, and sets the new Message object’s Text property to contain the following:

  • The text passed in to CreateForward

  • The TimeSent property of the original message

  • The name of the sender of the original message

  • The indented text of the original message

The new Message object is then returned from the function for further processing. To indent the text, the CreateForward function calls the IndentText function, also shown in the example, which in turn calls the WrapText function, shown last in the example. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required