Exemplo n.º 1
0
        public static MessageItem CreateReply(MessageItem originalItem, MessageItem template, CultureInfo culture, string xLoop, IRuleEvaluationContext context)
        {
            Util.ThrowOnNullArgument(originalItem, "originalItem");
            Util.ThrowOnNullArgument(template, "template");
            ExTraceGlobals.StorageTracer.Information(0L, "RuleMessageUtils::CreateReply.");
            MessageItem messageItem = null;
            bool        flag        = false;
            MessageItem result;

            try
            {
                messageItem = context.CreateMessageItem(InternalSchema.ContentConversionProperties);
                RuleReplyCreation ruleReplyCreation = new RuleReplyCreation(originalItem, messageItem, template, new ReplyForwardConfiguration(culture)
                {
                    XLoop = xLoop
                }, context.StoreSession is PublicFolderSession);
                ruleReplyCreation.PopulateProperties();
                flag   = true;
                result = messageItem;
            }
            finally
            {
                if (!flag && messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public static MessageItem CreateStockReply(MessageItem originalItem, string body, CultureInfo culture, string xLoop)
        {
            Util.ThrowOnNullArgument(originalItem, "originalItem");
            Util.ThrowOnNullArgument(body, "body");
            ExTraceGlobals.StorageTracer.Information(0L, "RuleMessageUtils::CreateStockReply.");
            MessageItem messageItem = null;
            bool        flag        = false;
            MessageItem result;

            try
            {
                messageItem = MessageItem.CreateInMemory(InternalSchema.ContentConversionProperties);
                using (MessageItem messageItem2 = MessageItem.CreateInMemory(InternalSchema.ContentConversionProperties))
                {
                    messageItem2[InternalSchema.ItemClass] = "IPM.Note";
                    using (TextWriter textWriter = messageItem2.Body.OpenTextWriter(BodyFormat.TextPlain))
                    {
                        textWriter.Write(body);
                        textWriter.Flush();
                    }
                    messageItem.Save(SaveMode.NoConflictResolution);
                    messageItem.Load(InternalSchema.ContentConversionProperties);
                    RuleReplyCreation ruleReplyCreation = new RuleReplyCreation(originalItem, messageItem, messageItem2, new ReplyForwardConfiguration(culture)
                    {
                        XLoop = xLoop
                    });
                    ruleReplyCreation.PopulateProperties();
                    flag   = true;
                    result = messageItem;
                }
            }
            finally
            {
                if (!flag && messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
            return(result);
        }