private void WriteApprovalRequestBody(Body destiniationBody, DsnHumanReadableWriter writer, ApprovalInformation info, bool writePreview)
        {
            if (writePreview)
            {
                Charset outputCharset;
                bool    flag = !ModerationApprovalRequestWriter.CheckInputOutputCharsetMatch(info.Codepages, this.originalMessageBodyCharset, out outputCharset);
                if (!flag && this.TryWriteApprovalRequestBodyWithPreview(destiniationBody, writer, info, outputCharset))
                {
                    return;
                }
                ModerationApprovalRequestWriter.diag.TraceError <bool, string>((long)this.GetHashCode(), "Failed to write preview for message.  Falling back to no preview. Charset mismatch:{0}. Approval data:{1}.", flag, this.initiationMessage.ApprovalData);
                info = writer.GetApprovalRequestMessageInformation(this.initiationMessage.Subject, this.originalSenderDisplayName, this.originalToFormattedLine, this.originalCcFormattedLine, this.moderatedRecipients, false, info.Culture);
            }
            BodyWriteConfiguration configuration = new BodyWriteConfiguration(Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml, info.MessageCharset.Name);

            using (Stream stream = destiniationBody.OpenWriteStream(configuration))
            {
                writer.WriteHtmlModerationBody(stream, info);
            }
        }
        public override bool WriteSubjectAndBody(MessageItemApprovalRequest approvalRequest, CultureInfo cultureInfo, out CultureInfo cultureInfoWritten)
        {
            cultureInfoWritten = cultureInfo;
            ModerationApprovalRequestWriter.diag.TraceDebug <CultureInfo>((long)this.GetHashCode(), "Generating approval request. cultureInfo={0}", cultureInfo);
            DsnHumanReadableWriter defaultDsnHumanReadableWriter = DsnHumanReadableWriter.DefaultDsnHumanReadableWriter;

            this.CacheDataFromOriginalMessage();
            if (this.originalMessageStream == null)
            {
                ModerationApprovalRequestWriter.diag.TraceError <string>((long)this.GetHashCode(), "No original message to write approval request body.  Approval data: {0}", this.initiationMessage.ApprovalData);
                return(false);
            }
            bool flag = !this.hasInlineAttachment && !this.isOpaqueMessage;

            if (this.hasInlineAttachment)
            {
                ModerationApprovalRequestWriter.diag.TraceDebug <string>((long)this.GetHashCode(), "Not writing preview for message with approval data: {0}, because it has inline attachment", this.initiationMessage.ApprovalData);
            }
            ApprovalInformation approvalRequestMessageInformation = defaultDsnHumanReadableWriter.GetApprovalRequestMessageInformation(this.initiationMessage.Subject, this.originalSenderDisplayName, this.originalToFormattedLine, this.originalCcFormattedLine, this.moderatedRecipients, flag, cultureInfo);

            approvalRequest.MessageItem.Subject = approvalRequestMessageInformation.Subject;
            this.WriteApprovalRequestBody(approvalRequest.MessageItem.Body, defaultDsnHumanReadableWriter, approvalRequestMessageInformation, flag);
            return(true);
        }