This issue can occur if you did not modify the
HTMLBody property of the reply to the CDO.Message correctly. When you modify the
HTMLBody property of a reply to a CDO.Message, you must make sure that you create properly formatted Hypertext Markup Language (HTML) and insert it correctly into the body of the message.
Although the message appears rearranged, the message is actually still formatted just as you created it.
NOTE: The following code is simply an example to reproduce this issue. However, the situation that this example describes is possible, and has been encountered with third-party developers. This article describes what occurs in this situation and provides a method that you can use to correct your code.
For example, consider the following Microsoft Visual Basic code:
Public Sub Main()
Dim MsgName
Dim szPrefix
Dim Original As CDO.Message
Dim Reply As CDO.Message
Dim strReplyText1 As String
Dim strReplyText2 As String
strReplyText1 = "<div style=""{font-Weight:700;}"">This is REPLY HTML 1</div>"
strReplyText2 = "<div style=""{font-Weight:700;}"">This is REPLY HTML 2</div>"
MsgName = "HTMLMessage.EML"
szPrefix = ""
Set Original = New CDO.Message
Original.DataSource.Open "file://./backofficestorage/cpr-ex-lc.dom/mbx/charliea/inbox/" & szPrefix & MsgName
Set Reply = Original.Reply
Reply.HTMLBody = strReplyText1 + Reply.HTMLBody
Reply.From = "Charlie Andersen<charliea@cpr-ex-lc.dom>"
Reply.Send
Set Reply = Nothing
Set Original = Nothing
szPrefix = "RE%3A "
Set Original = New CDO.Message
Original.DataSource.Open "file://./backofficestorage/cpr-ex-lc.dom/mbx/charliea/inbox/" & szPrefix & MsgName
Set Reply = Original.Reply
Reply.HTMLBody = strReplyText2 + Reply.HTMLBody
Reply.From = "Charlie Andersen<charliea@cpr-ex-lc.dom>"
Reply.Send
Set Reply = Nothing
Set Original = Nothing
End Sub
Synopsis
During the INITIAL reply, Collaboration Data Objects (CDO) parses the following original message:
Received: from SMTPStorm ([157.57.146.15]) by tigger-530.cpr-ex-lc.dom with Microsoft SMTPSVC(5.0.2195.4453);
Thu, 14 Feb 2002 09:36:19 -0600
From: Charlie Andersen<charliea@cpr-ex-lc.dom>
To: Charlie Andersen<charliea@cpr-ex-lc.dom>
Subject: HTMLMessage
MIME-Version: 1.0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<html><body>Type message Here</body></html>
CDO reformats the original message with the correct reply headers in the body of the message as follows:
<html><body>
<BR>-----Original Message-----<BR>
<B>From:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Sent:</B> 14 February, 2002 09:36
<BR>
<B>To:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Subject:</B> HTMLMessage
<BR>
<BR>
Type message Here</body></html>
At this point, the issue begins to compound. When you use the following syntax, you inadvertently create malformed HTML by placing HTML tags and text outside the <BODY> tags of the HTML stream:
Reply.HTMLBody = strReplyText1 + Reply.HTMLBody
You create a message with a body that is similar to the following:
<div>This is REPLY HTML 1</div>
<html><body>
<BR>-----Original Message-----<BR>
<B>From:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Sent:</B> 14 February, 2002 09:36
<BR>
<B>To:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Subject:</B> HTMLMessage
<BR>
<BR>
Type message Here</body></html>
This in itself renders correctly in HTML view (in Microsoft Internet Explorer) because there are no items that should be viewed above the reply or forward header information. Internet Explorer is a very forgiving browser for malformed HTML. All of the Microsoft Outlook and Microsoft Outlook Express windows that display HTML use some form of the Internet Explorer HTML parsing and viewing mechanism.
When a user replies to the second message, the issues that are created by your (the third-party developer) code are made evident; this code opens the reply to the first message, and then attempts to reply to that message with another message.
CDO correctly adds all of the correct reply or forwarding information to the
HTMLBody property and CDO correctly keeps all of that information inside the <BODY> tags of the message body.
CDO does not place the message text from the first reply in the <BODY> tag of the new message body because that message text was not found in the <BODY> tag to begin with (because of the programming error in the first reply). Therefore, when CDO commits the reply, the message is similar to the following:
<div>This is REPLY TEXT 1</div><html><body><BR>
-----Original Message-----<BR>
<B>From:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Sent:</B> 22 February, 2002 14:43
<BR>
<B>To:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Subject:</B> RE: HTMLMessage
<BR>
<BR>
<BR>
-----Original Message-----<BR>
<B>From:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Sent:</B> 14 February, 2002 09:36
<BR>
<B>To:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Subject:</B> HTMLMessage
<BR>
<BR>
Type message Here</body></html>
When you (the developer) run the following code, "<div>This is REPLY HTML 2</div>" (without the quotation marks) is inserted immediately preceding the text from the first reply:
Reply.HTMLBody = strReplyText2 + Reply.HTMLBody
Therefore, the message is displayed as follows:
<div>This is REPLY HTML 2</div>
<div>This is REPLY TEXT 1</div><html><body><BR>
-----Original Message-----<BR>
<B>From:</B> "Charlie Andersen" =
<charliea@cpr-ex-lc.dom>
<BR>
<B>Sent:</B> 22 February, 2002 14:43
<BR>
<B>To:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Subject:</B> RE: HTMLMessage
<BR>
<BR>
<BR>
-----Original Message-----<BR>
<B>From:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Sent:</B> 14 February, 2002 09:36
<BR>
<B>To:</B> "Charlie Andersen" <charliea@cpr-ex-lc.dom>
<BR>
<B>Subject:</B> HTMLMessage
<BR>
<BR>
Type message Here</body></html>
This renders the two lines of successive reply before any of the reply or forwarding information, and is nothing like what you intended.