Exemple #1
0
        public static Item CreatePostReplyItem(BodyFormat bodyFormat, PostItem item, UserContext userContext, StoreObjectId parentFolderId)
        {
            PostItem postItem = null;
            bool     flag     = true;

            try
            {
                string bodyPrefix = ReplyForwardUtilities.CreateReplyForwardHeader(bodyFormat, item, userContext, parentFolderId);
                string legacyDN   = null;
                OwaStoreObjectIdType owaStoreObjectIdType = Utilities.GetOwaStoreObjectIdType(userContext, item);
                if (owaStoreObjectIdType == OwaStoreObjectIdType.OtherUserMailboxObject)
                {
                    legacyDN = Utilities.GetMailboxSessionLegacyDN(item);
                }
                OwaStoreObjectId destinationFolderId        = OwaStoreObjectId.CreateFromFolderId(parentFolderId, owaStoreObjectIdType, legacyDN);
                OwaStoreObjectId scratchPadForImplicitDraft = Utilities.GetScratchPadForImplicitDraft(StoreObjectType.Post, destinationFolderId);
                try
                {
                    ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat);
                    replyForwardConfiguration.ConversionOptionsForSmime = Utilities.CreateInboundConversionOptions(userContext);
                    replyForwardConfiguration.AddBodyPrefix(bodyPrefix);
                    postItem = item.ReplyToFolder(scratchPadForImplicitDraft.GetSession(userContext), scratchPadForImplicitDraft.StoreObjectId, replyForwardConfiguration);
                }
                catch (StoragePermanentException ex)
                {
                    if (ex.InnerException is MapiExceptionNoCreateRight)
                    {
                        throw new OwaAccessDeniedException(LocalizedStrings.GetNonEncoded(995407892), ex);
                    }
                    throw ex;
                }
                ReplyForwardUtilities.CopyMessageClassificationProperties(item, postItem, userContext);
                Utilities.SetPostSender(postItem, userContext, Utilities.IsPublic(item));
                postItem.ConversationTopic = item.ConversationTopic;
                flag = false;
            }
            finally
            {
                if (flag && postItem != null)
                {
                    postItem.Dispose();
                    postItem = null;
                }
            }
            return(postItem);
        }
Exemple #2
0
        internal static void SetAlternateIrmBody(Item item, BodyFormat bodyFormat, UserContext userContext, StoreObjectId parentFolderId, RightsManagedMessageDecryptionStatus decryptionStatus, bool isProtectedVoicemail)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (parentFolderId == null)
            {
                throw new ArgumentNullException("parentFolderId");
            }
            if (!decryptionStatus.Failed)
            {
                return;
            }
            string text = ReplyForwardUtilities.CreateReplyForwardHeader(bodyFormat, item, userContext, parentFolderId);

            text += Utilities.GetAlternateBodyForIrm(userContext, bodyFormat, decryptionStatus, isProtectedVoicemail);
            ItemUtility.SetItemBody(item, bodyFormat, text);
        }
Exemple #3
0
        public static Item CreateForwardItem(BodyFormat bodyFormat, Item item, ReplyForwardFlags flags, UserContext userContext, StoreObjectId parentFolderId)
        {
            if (bodyFormat < (BodyFormat)0)
            {
                throw new ArgumentOutOfRangeException("bodyFormat", bodyFormat, "bodyFormat has an invalid value");
            }
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            MessageItem messageItem = null;
            bool        flag        = true;

            try
            {
                string text = string.Empty;
                if (!Utilities.IsFlagSet((int)flags, 2))
                {
                    text = ReplyForwardUtilities.CreateReplyForwardHeader(bodyFormat, item, userContext, parentFolderId);
                }
                ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat);
                replyForwardConfiguration.ConversionOptionsForSmime = Utilities.CreateInboundConversionOptions(userContext);
                replyForwardConfiguration.AddBodyPrefix(text);
                MessageItem      messageItem2;
                CalendarItemBase calendarItemBase;
                if ((messageItem2 = (item as MessageItem)) != null)
                {
                    messageItem = messageItem2.CreateForward(userContext.MailboxSession, userContext.DraftsFolderId, replyForwardConfiguration);
                    if (!(messageItem2 is MeetingMessage))
                    {
                        ReplyForwardUtilities.CopyMessageClassificationProperties(item, messageItem, userContext);
                    }
                    ReplyForwardUtilities.SmartReplyOrForward(messageItem2, messageItem, userContext);
                }
                else if ((calendarItemBase = (item as CalendarItemBase)) != null)
                {
                    messageItem = calendarItemBase.CreateForward(userContext.MailboxSession, userContext.DraftsFolderId, replyForwardConfiguration, null, null);
                }
                else
                {
                    PostItem postItem;
                    if ((postItem = (item as PostItem)) == null)
                    {
                        throw new ArgumentException("HTML reply forward headers can only be created for MessageItem or CalendarItemBase or PostItem. ");
                    }
                    messageItem = postItem.CreateForward(userContext.MailboxSession, userContext.DraftsFolderId, replyForwardConfiguration);
                }
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.ItemsCreated.Increment();
                }
                if (Utilities.IsFlagSet((int)flags, 1))
                {
                    ItemUtility.SetItemBody(messageItem, bodyFormat, text);
                }
                flag = false;
            }
            finally
            {
                if (flag && messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
            return(messageItem);
        }
Exemple #4
0
        private static Item CreateReplyOrReplyAllItem(BodyFormat bodyFormat, Item item, ReplyForwardFlags flags, bool replyAll, UserContext userContext, StoreObjectId parentFolderId)
        {
            if (bodyFormat < (BodyFormat)0)
            {
                throw new ArgumentOutOfRangeException("bodyFormat", bodyFormat, "bodyFormat has an invalid value");
            }
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            MessageItem messageItem = null;
            bool        flag        = true;

            try
            {
                bool   flag2 = true;
                string text  = string.Empty;
                if (!Utilities.IsFlagSet((int)flags, 2))
                {
                    text = ReplyForwardUtilities.CreateReplyForwardHeader(bodyFormat, item, userContext, parentFolderId);
                }
                ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat);
                replyForwardConfiguration.ConversionOptionsForSmime = Utilities.CreateInboundConversionOptions(userContext);
                replyForwardConfiguration.AddBodyPrefix(text);
                MessageItem      messageItem2;
                CalendarItemBase calendarItemBase;
                PostItem         postItem;
                if ((messageItem2 = (item as MessageItem)) != null)
                {
                    if (replyAll)
                    {
                        messageItem = messageItem2.CreateReplyAll(userContext.MailboxSession, userContext.DraftsFolderId, replyForwardConfiguration);
                    }
                    else
                    {
                        messageItem = messageItem2.CreateReply(userContext.MailboxSession, userContext.DraftsFolderId, replyForwardConfiguration);
                    }
                    ReplyForwardUtilities.SmartReplyOrForward(messageItem2, messageItem, userContext);
                    ReplyForwardUtilities.CopyMessageClassificationProperties(item, messageItem, userContext);
                }
                else if ((calendarItemBase = (item as CalendarItemBase)) != null)
                {
                    if (calendarItemBase.IsMeeting)
                    {
                        if (replyAll)
                        {
                            messageItem = calendarItemBase.CreateReplyAll(userContext.MailboxSession, userContext.DraftsFolderId, replyForwardConfiguration);
                        }
                        else
                        {
                            messageItem = calendarItemBase.CreateReply(userContext.MailboxSession, userContext.DraftsFolderId, replyForwardConfiguration);
                        }
                    }
                    else
                    {
                        flag2 = false;
                    }
                }
                else if ((postItem = (item as PostItem)) != null)
                {
                    if (replyAll)
                    {
                        messageItem = postItem.CreateReplyAll(userContext.MailboxSession, userContext.DraftsFolderId, replyForwardConfiguration);
                    }
                    else
                    {
                        messageItem = postItem.CreateReply(userContext.MailboxSession, userContext.DraftsFolderId, replyForwardConfiguration);
                    }
                }
                else
                {
                    flag2 = false;
                }
                if (!flag2)
                {
                    throw new OwaOperationNotSupportedException(LocalizedStrings.GetNonEncoded(293574673));
                }
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.ItemsCreated.Increment();
                }
                if (Utilities.IsFlagSet((int)flags, 1))
                {
                    ItemUtility.SetItemBody(messageItem, bodyFormat, text);
                }
                flag = false;
            }
            catch (NotSupportedException ex)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "Unable to create a Reply or ReplyAll item. Exception {0}", ex.Message);
                throw new OwaInvalidRequestException("Unable to create a Reply or ReplyAll item.");
            }
            finally
            {
                if (flag && messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
            return(messageItem);
        }