FYI: MSDN Doco Correction: System.Net.Mail AlternateView doc error...
Ryan Rinaldi does a good job of pointing out an error in our MSDN documentation on the AlternateView class, part of System.Net.Mail. Our product documentation for the AlternateViews property in MSDN and in the SDK includes a sample for adding an HTML body to a MailMessage. The error is in the use of the AlternateView constructor…
AlternateView alternate = new AlternateView(body, MediaTypeNames.Text.Html); |
While this use of the constructor does fit one of its signatures and the code will compile it is not correct in that the constructor is looking for a file path in the first string not the body text. In order to create an HTML AlternateView from an HTML string such as the body created in this example, use the static CreateAlternateViewFromString method as seen below…
AlternateView alternate = AlternateView.CreateAlternateViewFromString(body, MediaTypeNames.Text.HTML); |
…I wish it was as simple as firing up notepad and correcting the documentation but it isn’t. We will get this content corrected. I definitely appreciate Ryan and my customer for pointing out this error…
…NOTE: An important note about how Support Services works here at Microsoft as it relates to this issue. A customer brought this documentation error to my attention through a support case at Microsoft. Please note that in the case of reporting a bug with our products or documentation, you will be refunded any payment made to Microsoft for a support incident. If you are still hesitant to open a case for whatever reason please contact me using the email link or contact our newsgroups. We do listen and we do want to improve our products and their documentation…