Article ID: 178789
Article Last Modified on 5/16/2005
'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.
171440 INFO: Where to Acquire the CDO (1.x) Libraries
Keywords: kbhowto kbmsg kbcode KB178789