When you programmatically set a header field to an empty
string, the related header does not stay in sync. The initial value is still
displayed when you run the query.
This problem occurs because when you set the interface
property to an empty string, the related header is deleted. ActiveX Data
Objects (ADO) looks for the field because it existed previously. Collaboration Data Objects (CDO) returns
the DBSTATUS_E_DOESNOTEXIST status code for the field. ADO sets the status of the fields to
adFieldDoesNotExist, but it does not update the values.
To work around this problem, explicitly set the header field
to an empty string. For example, you can use the following code sample:
objMsg.Fields("urn:schemas:httpmail:subject") = ""
objMsg.Fields("urn:schemas:mailheader:subject") = ""
Microsoft has confirmed that this is a bug in the Microsoft
products that are listed in the "Applies to"
section.
The following code sample illustrates this problem:
Dim objMsg As New CDO.Message
objMsg.Subject = "test subject"
Debug.Print objMsg.Fields("urn:schemas:httpmail:subject") 'Output: "test subject"
Debug.Print objMsg.Fields("urn:schemas:mailheader:subject") 'Output: "test subject"
objMsg.Subject = ""
objMsg.Fields.Resync
Debug.Print objMsg.Fields("urn:schemas:httpmail:subject") 'Output: "test subject"
Debug.Print objMsg.Fields("urn:schemas:mailheader:subject") 'Output: "test subject"
For more information, visit the following MSDN Web sites: