コード例 #1
0
        // Token: 0x06002FC9 RID: 12233 RVA: 0x0011611C File Offset: 0x0011431C
        internal static bool SetBody(Item item, string body, Markup markup, StoreObjectType storeObjectType, UserContext userContext)
        {
            bool flag = false;

            switch (markup)
            {
            case Markup.Html:
            {
                string                 targetCharsetName;
                BodyCharsetFlags       bodyCharsetOptions     = BodyConversionUtilities.GetBodyCharsetOptions(userContext, out targetCharsetName);
                BodyFormat             targetFormat           = (storeObjectType != StoreObjectType.CalendarItem && storeObjectType != StoreObjectType.MeetingMessage) ? BodyFormat.TextHtml : BodyFormat.ApplicationRtf;
                BodyWriteConfiguration bodyWriteConfiguration = new BodyWriteConfiguration(BodyFormat.TextHtml);
                bodyWriteConfiguration.SetTargetFormat(targetFormat, targetCharsetName, bodyCharsetOptions);
                OwaSafeHtmlInboundCallbacks owaSafeHtmlInboundCallbacks = null;
                owaSafeHtmlInboundCallbacks = new OwaSafeHtmlInboundCallbacks(item, userContext);
                bodyWriteConfiguration.SetHtmlOptions(HtmlStreamingFlags.None, owaSafeHtmlInboundCallbacks);
                try
                {
                    Body body2 = item.Body;
                    if (userContext.IsIrmEnabled && Utilities.IsIrmDecrypted(item))
                    {
                        body2 = ((RightsManagedMessageItem)item).ProtectedBody;
                    }
                    using (TextWriter textWriter = body2.OpenTextWriter(bodyWriteConfiguration))
                    {
                        textWriter.Write(body);
                    }
                }
                catch (InvalidCharsetException innerException)
                {
                    throw new OwaEventHandlerException(LocalizedStrings.GetNonEncoded(1825027020), LocalizedStrings.GetNonEncoded(1825027020), innerException);
                }
                catch (TextConvertersException innerException2)
                {
                    throw new OwaEventHandlerException(LocalizedStrings.GetNonEncoded(1825027020), LocalizedStrings.GetNonEncoded(1825027020), innerException2);
                }
                Utilities.MakeModifiedCalendarItemOccurrence(item);
                bool flag2 = false;
                if (owaSafeHtmlInboundCallbacks != null)
                {
                    flag2 = owaSafeHtmlInboundCallbacks.AttachmentNeedsSave();
                }
                if (flag2 && !Utilities.IsClearSigned(item))
                {
                    flag = AttachmentUtility.ApplyAttachmentsUpdates(item, owaSafeHtmlInboundCallbacks);
                    item.Load();
                }
                break;
            }

            case Markup.PlainText:
                ItemUtility.SetItemBody(item, BodyFormat.TextPlain, body);
                flag = AttachmentUtility.PromoteInlineAttachments(item);
                if (flag)
                {
                    item.Load();
                }
                break;
            }
            return(flag);
        }