예제 #1
0
        internal static void CopyBodyWithPrefix(Body sourceBody, Body targetBody, ReplyForwardConfiguration configuration, BodyConversionCallbacks callbacks)
        {
            ReplyForwardCommon.CheckRtf(sourceBody.RawFormat, targetBody.RawFormat);
            BodyReadConfiguration  configuration2         = new BodyReadConfiguration(sourceBody.RawFormat, sourceBody.RawCharset.Name);
            BodyWriteConfiguration bodyWriteConfiguration = new BodyWriteConfiguration(sourceBody.RawFormat, sourceBody.RawCharset.Name);

            bodyWriteConfiguration.SetTargetFormat(configuration.TargetFormat, sourceBody.Charset);
            if (!string.IsNullOrEmpty(configuration.BodyPrefix))
            {
                bodyWriteConfiguration.AddInjectedText(configuration.BodyPrefix, null, configuration.BodyPrefixFormat);
            }
            if (callbacks.HtmlCallback != null || callbacks.RtfCallback != null)
            {
                bodyWriteConfiguration.HtmlCallback = callbacks.HtmlCallback;
                bodyWriteConfiguration.RtfCallback  = callbacks.RtfCallback;
                if (!configuration.ShouldSkipFilterHtmlOnBodyWrite)
                {
                    bodyWriteConfiguration.HtmlFlags = HtmlStreamingFlags.FilterHtml;
                }
            }
            using (Stream stream = sourceBody.OpenReadStream(configuration2))
            {
                using (Stream stream2 = targetBody.OpenWriteStream(bodyWriteConfiguration))
                {
                    Util.StreamHandler.CopyStreamData(stream, stream2);
                }
            }
        }
예제 #2
0
        public static MessageItem CreateRedirect(MessageItem originalItem, CultureInfo culture, string imceaDomain, string xLoop, IRuleEvaluationContext context)
        {
            Util.ThrowOnNullArgument(originalItem, "originalItem");
            ExTraceGlobals.StorageTracer.Information(0L, "RuleMessageUtils::CreateRedirect.");
            MessageItem messageItem = null;
            bool        flag        = false;
            MessageItem result;

            try
            {
                messageItem = context.CreateMessageItem(InternalSchema.ContentConversionProperties);
                Item.CopyItemContent(originalItem, messageItem);
                messageItem.Delete(InternalSchema.InternetMessageId);
                messageItem.Delete(InternalSchema.MimeSkeleton);
                messageItem.CharsetDetector.DetectionOptions = originalItem.CharsetDetector.DetectionOptions;
                messageItem.SaveFlags |= (originalItem.SaveFlags | PropertyBagSaveFlags.IgnoreMapiComputedErrors);
                ReplyForwardCommon.UpdateXLoop(originalItem, messageItem, xLoop);
                flag   = true;
                result = messageItem;
            }
            finally
            {
                if (!flag && messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
            return(result);
        }
        protected override void BuildBody(BodyConversionCallbacks callbacks)
        {
            RightsManagedMessageItem rightsManagedMessageItem  = this.originalItem as RightsManagedMessageItem;
            RightsManagedMessageItem rightsManagedMessageItem2 = this.newItem as RightsManagedMessageItem;

            ReplyForwardCommon.CopyBodyWithPrefix(rightsManagedMessageItem.ProtectedBody, rightsManagedMessageItem2.ProtectedBody, this.parameters, callbacks);
        }
예제 #4
0
 protected override void BuildBody(BodyConversionCallbacks callbacks)
 {
     if (!base.IsResourceDelegationMessage && (this.newItem is MeetingMessage || base.TreatAsMeetingMessage) && !string.IsNullOrEmpty(this.parameters.BodyPrefix))
     {
         this.BuildMeetingMessageBody(callbacks);
         return;
     }
     ReplyForwardCommon.CopyBodyWithPrefix(this.originalItem.Body, this.newItem.Body, this.parameters, callbacks);
 }
예제 #5
0
        internal static void BuildReplyRecipientsFromMessage(MessageItem message, MessageItem sourceMessage, bool isReplyAll, bool shouldUseSender, bool useReplyTo)
        {
            if (!useReplyTo || sourceMessage.ReplyTo == null || sourceMessage.ReplyTo.Count == 0)
            {
                if (shouldUseSender && sourceMessage.Sender != null)
                {
                    if (!isReplyAll || !ReplyForwardCommon.ParticipantIsSender(message.Session, sourceMessage.Sender))
                    {
                        message.Recipients.Add(sourceMessage.Sender, RecipientItemType.To);
                    }
                }
                else if (sourceMessage.From != null && (!isReplyAll || !ReplyForwardCommon.ParticipantIsSender(message.Session, sourceMessage.From)))
                {
                    message.Recipients.Add(sourceMessage.From, RecipientItemType.To);
                }
            }
            else
            {
                foreach (Participant participant in sourceMessage.ReplyTo)
                {
                    if (!isReplyAll || !ReplyForwardCommon.ParticipantIsSender(message.Session, participant))
                    {
                        message.Recipients.Add(participant, RecipientItemType.To);
                    }
                }
            }
            if (!isReplyAll)
            {
                return;
            }
            bool flag = message.Recipients.Count == 0;

            foreach (Recipient recipient in sourceMessage.Recipients)
            {
                if (!message.Recipients.Contains(recipient.Participant) && (!ReplyForwardCommon.ParticipantIsSender(message.Session, recipient.Participant) || (flag && sourceMessage.Recipients.Count <= 1)) && recipient.RecipientItemType != RecipientItemType.Unknown && recipient.RecipientItemType != RecipientItemType.Bcc)
                {
                    message.Recipients.Add(recipient.Participant, recipient.RecipientItemType);
                }
            }
        }
예제 #6
0
        private void BuildRecipients()
        {
            bool useReplyTo = true;

            if (this is OofReplyCreation || this is RuleReplyCreation)
            {
                useReplyTo = false;
            }
            if (this.originalItem is MessageItem)
            {
                ReplyForwardCommon.BuildReplyRecipientsFromMessage(this.newItem as MessageItem, this.originalItem as MessageItem, this.isReplyAll, this.shouldUseSender, useReplyTo);
                return;
            }
            if (this.originalItem is CalendarItemBase)
            {
                this.BuildRecipientsFromCalendarItem();
                return;
            }
            if (this.originalItem is PostItem)
            {
                this.BuildRecipientsFromPostItem();
            }
        }
예제 #7
0
 protected override void UpdateNewItemProperties()
 {
     base.UpdateNewItemProperties();
     ReplyForwardCommon.BuildReplyRecipientsFromMessage(this.newItem as MessageItem, this.originalItem as MessageItem, false, true, true);
     this.newItem.SafeSetProperty(InternalSchema.Importance, Importance.Normal);
     this.newItem.SafeSetProperty(InternalSchema.IsVotingResponse, 1);
     this.newItem.SafeSetProperty(InternalSchema.ReportTag, this.originalItem.PropertyBag.GetValueOrDefault <byte[]>(InternalSchema.ReportTag));
     this.newItem.SafeSetProperty(InternalSchema.VotingResponse, this.votingResponse);
     if (this.originalItem.ClassName.Equals("IPM.Note.Microsoft.Approval.Request", StringComparison.OrdinalIgnoreCase))
     {
         MessageItem messageItem = this.originalItem as MessageItem;
         string[]    array       = (string[])messageItem.VotingInfo.GetOptionsList();
         int         num         = Array.IndexOf <string>(array, this.votingResponse);
         if (num == 0)
         {
             this.newItem.SafeSetProperty(InternalSchema.ItemClass, "IPM.Note.Microsoft.Approval.Reply.Approve");
             return;
         }
         if (num == 1)
         {
             this.newItem.SafeSetProperty(InternalSchema.ItemClass, "IPM.Note.Microsoft.Approval.Reply.Reject");
         }
     }
 }
예제 #8
0
        protected virtual void UpdateNewItemProperties()
        {
            IExchangePrincipal exchangePrincipal = (this.newItem.Session == null) ? null : this.newItem.Session.MailboxOwner;
            MailboxSession     mailboxSession    = this.newItem.Session as MailboxSession;

            if (mailboxSession != null && exchangePrincipal != null)
            {
                PostItem postItem = this.newItem as PostItem;
                if (postItem != null)
                {
                    postItem.Sender = new Participant(exchangePrincipal);
                }
                else
                {
                    ((MessageItem)this.newItem).Sender = new Participant(exchangePrincipal);
                }
            }
            string text           = null;
            string valueOrDefault = this.originalItem.GetValueOrDefault <string>(InternalSchema.InternetMessageId);

            if (!string.IsNullOrEmpty(valueOrDefault))
            {
                text = valueOrDefault;
            }
            string text2 = null;

            valueOrDefault = this.originalItem.GetValueOrDefault <string>(InternalSchema.InReplyTo);
            if (!string.IsNullOrEmpty(valueOrDefault))
            {
                text2 = valueOrDefault;
            }
            this.newItem.SafeSetProperty(InternalSchema.InReplyTo, text);
            StringBuilder stringBuilder = new StringBuilder(128);

            valueOrDefault = this.originalItem.GetValueOrDefault <string>(InternalSchema.InternetReferences);
            if (!string.IsNullOrEmpty(valueOrDefault))
            {
                stringBuilder.Append(valueOrDefault);
            }
            else if (text2 != null)
            {
                stringBuilder.Append(text2);
            }
            if (text != null)
            {
                if (stringBuilder.Length + 1 + text.Length > 32768 || stringBuilder.Length == 0)
                {
                    stringBuilder.Clear();
                    stringBuilder.Append(text);
                }
                else
                {
                    stringBuilder.Append(',');
                    stringBuilder.Append(text);
                }
            }
            this.newItem.SafeSetProperty(InternalSchema.InternetReferences, stringBuilder.ToString());
            this.newItem.SafeSetProperty(InternalSchema.Categories, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.Categories), typeof(string[]), null));
            byte[]            parentBytes       = this.originalItem.TryGetProperty(InternalSchema.ConversationIndex) as byte[];
            ConversationIndex conversationIndex = ConversationIndex.CreateFromParent(parentBytes);

            this.newItem.SafeSetProperty(InternalSchema.ConversationIndex, conversationIndex.ToByteArray());
            ConversationId valueOrDefault2 = this.originalItem.GetValueOrDefault <ConversationId>(InternalSchema.ConversationFamilyId);

            this.newItem.SafeSetProperty(InternalSchema.ConversationFamilyId, valueOrDefault2);
            object propValue = this.originalItem.TryGetProperty(InternalSchema.SupportsSideConversation);

            this.newItem.SafeSetProperty(InternalSchema.SupportsSideConversation, propValue);
            ConversationCreatorSidCalculatorFactory conversationCreatorSidCalculatorFactory = new ConversationCreatorSidCalculatorFactory(XSOFactory.Default);
            IConversationCreatorSidCalculator       conversationCreatorSidCalculator;

            byte[] propValue2;
            if (conversationCreatorSidCalculatorFactory.TryCreate(mailboxSession, exchangePrincipal, out conversationCreatorSidCalculator) && conversationCreatorSidCalculator.TryCalculateOnReply(conversationIndex, out propValue2))
            {
                this.newItem.SafeSetProperty(ItemSchema.ConversationCreatorSID, propValue2);
            }
            bool?valueAsNullable = this.originalItem.GetValueAsNullable <bool>(InternalSchema.ConversationIndexTracking);

            if (valueAsNullable != null && valueAsNullable.Value)
            {
                this.newItem.SafeSetProperty(InternalSchema.ConversationIndexTracking, true);
            }
            this.newItem.SafeSetProperty(InternalSchema.ConversationTopic, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.ConversationTopic), typeof(string), StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.NormalizedSubjectInternal), typeof(string), null)));
            this.newItem.SafeSetProperty(InternalSchema.Sensitivity, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.Sensitivity), typeof(Sensitivity), Sensitivity.Normal));
            this.newItem.SafeSetProperty(InternalSchema.OriginalSensitivity, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.OriginalSensitivity), typeof(Sensitivity), Sensitivity.Normal));
            this.newItem.SafeSetProperty(InternalSchema.IsReadReceiptRequested, false);
            this.newItem.SafeSetProperty(InternalSchema.IsDeliveryReceiptRequested, false);
            this.newItem.SafeSetProperty(InternalSchema.IsReplyRequested, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.IsReplyRequested), typeof(bool), null));
            this.newItem.SafeSetProperty(InternalSchema.IsResponseRequested, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.IsResponseRequested), typeof(bool), null));
            this.newItem.SafeSetProperty(InternalSchema.NativeBlockStatus, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.NativeBlockStatus), typeof(int), null));
            object obj = this.originalItem.TryGetProperty(InternalSchema.IconIndex);

            if (!PropertyError.IsPropertyError(obj))
            {
                IconIndex iconIndex = (IconIndex)obj;
                if (iconIndex != IconIndex.Default)
                {
                    iconIndex = ReplyForwardCommon.GetIconIndexForNewItem(iconIndex);
                    this.newItem.SafeSetProperty(InternalSchema.IconIndex, iconIndex);
                }
            }
            ReplyForwardCommon.UpdateXLoop(this.originalItem, this.newItem, this.parameters.XLoop);
        }
예제 #9
0
 protected virtual void BuildBody(BodyConversionCallbacks callbacks)
 {
     ReplyForwardCommon.CopyBodyWithPrefix(this.originalItem.Body, this.newItem.Body, this.parameters, callbacks);
 }