Messages that are formatted according to the Multipurpose Internet Mail Extensions (MIME) specification are divided into parts. The top part is referred to as the root, and additional parts are referred to as body parts. You can set the content class and the custom property on the attachment body part. When the sendusing field is set to the cdoSendUsingExchange enumeration, the content class and custom property do not persist to the MIME stream of the received message.
↑ Back to the top
Setting the content class and custom properties is not supported on the attachment body part level. Setting these properties is only supported at the root of the message.
↑ Back to the top
Steps to Reproduce Behavior
- In Microsoft Visual Basic, create a new Standard EXE project.
- Add a button to the default form and paste the following code into the button's Click event:
Dim iMsg As CDO.Message
Dim iConf As CDO.Configuration
Dim iBp As CDO.IBodyPart
Dim Flds As Fields
Dim Strm As Stream
Set iMsg = CreateObject("CDO.Message")
Set iConf = iMsg.Configuration
iConf("http://schemas.microsoft.com/cdo/configuration/sendusing") _
= cdoSendUsingExchange
iConf.Fields.Update
'TO DO: Change From and To
iMsg.To = "someone@somewhere.com"
iMsg.From = "someone@somewhere.com"
iMsg.Subject = "subject"
iMsg.TextBody = "text body"
Set iBp = iMsg.AddAttachment("")
iBp.ContentClass = "urn:somewhere:mycc"
Set Flds = iBp.Fields
Flds("urn:schemas:mailheader:content-type") = "text/html"
Flds("urn:schemas:mailheader:content-class") = "urn:somewhere:mycc"
Flds("urn:schemas:mailheader:mycustomprop") = "myproperty"
Flds.Update
Set Strm = iBp.GetDecodedContentStream
Strm.WriteText "Attachment body part new text", adWriteLine
Strm.Flush
iMsg.Fields.Update
iMsg.Send
Set iMsg = Nothing
- Change the e-mail address of iMsg.To and iMsg.From in the code.
- Add a reference to Microsoft CDO For Exchange 2000 Library and Microsoft ActiveX Data Objects 2.5 Library.
- Run the program and click the button to send the message.
- Observe the MIME stream of the received message. The attachment body part's ContentClass property and urn:schemas:mailheader:mycustomprop custom property are not persisted.
↑ Back to the top