private bool TryWriteApprovalRequestBodyWithPreview(Body destiniationBody, DsnHumanReadableWriter approvalRequestWriter, ApprovalInformation info, Charset outputCharset)
        {
            if (this.originalEmailMessage == null)
            {
                return(false);
            }
            TextConverter textConverter;

            if (this.originalMesssageBodyFormat == Microsoft.Exchange.Data.Transport.Email.BodyFormat.Rtf)
            {
                textConverter = new RtfToHtml
                {
                    Header             = approvalRequestWriter.GetHtmlModerationBody(info),
                    HeaderFooterFormat = HeaderFooterFormat.Html,
                    OutputEncoding     = outputCharset.GetEncoding()
                };
            }
            else if (this.originalMesssageBodyFormat == Microsoft.Exchange.Data.Transport.Email.BodyFormat.Text)
            {
                textConverter = new TextToHtml
                {
                    Header             = approvalRequestWriter.GetHtmlModerationBody(info),
                    HeaderFooterFormat = HeaderFooterFormat.Html,
                    InputEncoding      = this.originalMessageBodyCharset.GetEncoding(),
                    OutputEncoding     = outputCharset.GetEncoding()
                };
            }
            else
            {
                if (this.originalMesssageBodyFormat != Microsoft.Exchange.Data.Transport.Email.BodyFormat.Html)
                {
                    return(false);
                }
                textConverter = new HtmlToHtml
                {
                    Header             = approvalRequestWriter.GetHtmlModerationBody(info),
                    HeaderFooterFormat = HeaderFooterFormat.Html,
                    InputEncoding      = this.originalMessageBodyCharset.GetEncoding(),
                    OutputEncoding     = outputCharset.GetEncoding()
                };
            }
            BodyWriteConfiguration configuration = new BodyWriteConfiguration(Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml, outputCharset);

            using (Stream stream = destiniationBody.OpenWriteStream(configuration))
            {
                using (Stream contentReadStream = this.originalEmailMessage.Body.GetContentReadStream())
                {
                    try
                    {
                        textConverter.Convert(contentReadStream, stream);
                    }
                    catch (ExchangeDataException arg)
                    {
                        ModerationApprovalRequestWriter.diag.TraceDebug <ExchangeDataException>(0L, "Approval request with inline preview failed {0}", arg);
                        return(false);
                    }
                }
            }
            return(true);
        }
        // Token: 0x0600003F RID: 63 RVA: 0x00004608 File Offset: 0x00002808
        private bool TryWriteNotificationWithAppendedComments(DsnHumanReadableWriter notificationWriter, MessageItem rejectItem, StreamAttachment commentAttachment, ApprovalInformation info)
        {
            bool     result             = true;
            string   htmlModerationBody = notificationWriter.GetHtmlModerationBody(info);
            Charset  textCharset        = commentAttachment.TextCharset;
            Encoding inputEncoding      = null;

            if (textCharset == null || !textCharset.TryGetEncoding(out inputEncoding))
            {
                return(false);
            }
            Charset charset = textCharset;

            if (!ModeratedDLApplication.IsEncodingMatch(info.Codepages, textCharset.CodePage))
            {
                charset = Charset.UTF8;
            }
            BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextHtml, charset.Name);

            using (Stream stream = rejectItem.Body.OpenWriteStream(configuration))
            {
                HtmlToHtml htmlToHtml = new HtmlToHtml();
                htmlToHtml.Header             = htmlModerationBody;
                htmlToHtml.HeaderFooterFormat = HeaderFooterFormat.Html;
                htmlToHtml.InputEncoding      = inputEncoding;
                htmlToHtml.OutputEncoding     = charset.GetEncoding();
                try
                {
                    using (Stream contentStream = commentAttachment.GetContentStream(PropertyOpenMode.ReadOnly))
                    {
                        htmlToHtml.Convert(contentStream, stream);
                        stream.Flush();
                    }
                }
                catch (ExchangeDataException arg)
                {
                    ModeratedDLApplication.diag.TraceDebug <ExchangeDataException>(0L, "Attaching comments failed with {0}", arg);
                    result = false;
                }
            }
            return(result);
        }