// The HTML version should take precedent over the plain text if it is available MessagePart preferredVersion = FindFirstHtmlVersion(); if ( preferredVersion != null ) { // Make sure that the IsBodyHtml property is being set correctly for our content message.IsBodyHtml = true; } else { // otherwise use the first plain text version as the body, if it exists preferredVersion = FindFirstPlainTextVersion(); } if (preferredVersion != null) { message.Body = preferredVersion.GetBodyAsText(); message.BodyEncoding = preferredVersion.BodyEncoding; } // Add body and alternative views (html and such) to the message IEnumerable textVersions = FindAllTextVersions(); foreach (MessagePart textVersion in textVersions) { // The textVersions also contain the preferred version, therefore // we should skip that one if (textVersion == preferredVersion) continue; MemoryStream stream = new MemoryStream(textVersion.Body); AlternateView alternative = new AlternateView(stream); alternative.ContentId = textVersion.ContentId; alternative.ContentType = textVersion.ContentType; message.AlternateViews.Add(alternative); }