|
using System.Net.Mail;
using System.Net.Mime;
namespace MailMergeLib
{
internal class PlainBodyBuilder : BodyBuilderBase
{
private readonly string _plainText;
public PlainBodyBuilder(string plainText)
{
_plainText = plainText;
}
/// <summary>
/// Gets the ready made body part for a mail message.
/// </summary>
public override AlternateView Body
{
get
{
AlternateView plainBody = AlternateView.CreateAlternateViewFromString(_plainText,
CharacterEncoding, MediaTypeNames.Text.Plain);
plainBody.TransferEncoding = Tools.IsSevenBit(plainBody.ContentStream)
? TransferEncoding.SevenBit
: TextTransferEncoding != TransferEncoding.SevenBit
? TextTransferEncoding
: TransferEncoding.QuotedPrintable;
plainBody.ContentType.CharSet = CharacterEncoding.HeaderName; // RFC 2045 Section 5.1 - http://www.ietf.org
return plainBody;
}
}
/// <summary>
/// Get the text representation of the source document
/// </summary>
public override string DocText
{
get { return _plainText; }
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.