Microsoft KB Archive/178789

From BetaArchive Wiki
Knowledge Base


Article ID: 178789

Article Last Modified on 5/16/2005



APPLIES TO

  • Microsoft Collaboration Data Objects 1.2
  • Microsoft Collaboration Data Objects 1.21



This article was previously published under Q178789

SUMMARY

The Forward method has been added to the Collaboration Data Objects (1.2) library. When you use the Forward method, it may not perform as desired because the body of the message is not copied to the message to be forwarded. This behavior is by design.

This article contains a Visual Basic code sample showing how to make this work.

MORE INFORMATION

This problem stems from the fact that the Collaboration Data Objects (1.x) library only supports non-RTF (Rich Text Format) by default, but can also be extended to support RTF. This method explicitly leaves the decision up to the developer to determine how a message is to be forwarded.

   'This code sample is dependent upon the CDO version 1.2 library being
   'installed on the target computer.
   '
   Dim objSession As MAPI.Session
   Dim objMsgColl As Messages
   Dim objMsg1 As Message
   Dim objFwdMsg As Message

   Private Sub Form_Load()
   'Create Session and Logon.
   Set objSession = CreateObject("mapi.session")
   objSession.Logon
   Set objMsgColl = objSession.Inbox.Messages
   'First Message.
   Set objMsg1 = objMsgColl.GetFirst
   Set objFwdMsg = objMsg1.Forward
   'BEGIN objFwdMsg BODY CONSTRUCTION
   '
   'For RTF in the body, uncomment the following lines of code.
   'For plain text, uncomment the first line, which isn't really
   'required for RTF, except that if you happen to forward the message
   'to a client that cannot read RTF, populating this property allows
   'that client to display the non-RTF variant of the body.
   '
   'objFwdMsg.Text = objMsg1.Text
   'objFwdMsg.Fields.Add CdoPR_RTF_COMPRESSED, _
   'objMsg1.Fields(&H10090102).Value
   '
   'END objFwdMsg BODY CONSTRUCTION
   objFwdMsg.Recipients.Add Name:="YourRecipEmailNameHere"
   objFwdMsg.Recipients.Resolve
      objFwdMsg.Send

      objSession.Logoff
      Set objSession = Nothing
      Unload Me

      End Sub
                

NOTE: This process of copying the compressed RTF stream to the new message also works for the CDO version 1.1 library. However, version 1.1 of the CDO library does not support the Forward method, so a "Forward" would need to be emulated by copying one field at a time from the fields collection of the original message to the target message.

REFERENCES

For information on where to acquire the most recent version of the CDO (1.x) library tested for client-side use, please see the following article in the Microsoft Knowledge Base:

171440 INFO: Where to Acquire the CDO (1.x) Libraries


Keywords: kbhowto kbmsg kbcode KB178789