Microsoft KB Archive/922784

From BetaArchive Wiki
Knowledge Base


There is a documentation error in the code example of the "MailMessage.AlternateViews Property" MSDN article

Article ID: 922784

Article Last Modified on 12/3/2007



APPLIES TO

  • Microsoft .NET Framework 2.0




INTRODUCTION

This article discusses a documentation error that occurs in the code example of the "MailMessage.AlternateViews Property" MSDN article in the MSDN library.

MORE INFORMATION

The code example in this MSDN article is incorrect at the line where the body string is passed to the AlternateView constructor. The current block of code provides an HTML stream to the constructor. The current block of code reads as follows:

// Add the alternate body to the message.
    AlternateView alternate = new AlternateView(body, MediaTypeNames.Text.Html);
    message.AlternateViews.Add(alternate);

The current block of code does not work because the constructor is looking for a file path. The corrected block of code reads as follows:

// Add the alternate body to the message.
    AlternateView alternate = AlternateView.CreateAlternateViewFromString(body);
    message.AlternateViews.Add(alternate);

For more information about the original MSDN article, visit the following Microsoft Developer Network (MSDN) Web site:

Keywords: kbtshoot kbbug kbfix kbdocerr KB922784