Example #1
0
        private static string CreatePostTextReplyForwardHeader(PostItem item, UserContext userContext, string fromLabel, string from, string postToFolderName)
        {
            StringBuilder stringBuilder = new StringBuilder(100);

            if (userContext.IsFeatureEnabled(Feature.Signature) && userContext.UserOptions.AutoAddSignature)
            {
                stringBuilder.Append(userContext.UserOptions.SignatureText);
            }
            stringBuilder.Append("\n");
            stringBuilder.Append("\n________________________________________\n");
            if (!string.IsNullOrEmpty(from))
            {
                stringBuilder.Append(fromLabel);
                stringBuilder.Append(" ");
                stringBuilder.Append(from);
                stringBuilder.Append("\n");
            }
            item.TryGetProperty(ItemSchema.SentTime);
            ExDateTime postedTime = item.PostedTime;

            stringBuilder.Append(LocalizedStrings.GetNonEncoded(1890363921));
            stringBuilder.Append(" ");
            stringBuilder.AppendFormat(Strings.SentTime, item.PostedTime.ToLongDateString(), item.PostedTime.ToString(userContext.UserOptions.TimeFormat));
            stringBuilder.Append("\n");
            stringBuilder.Append(LocalizedStrings.GetNonEncoded(737701919));
            stringBuilder.Append(" ");
            stringBuilder.Append(postToFolderName);
            stringBuilder.Append("\n");
            stringBuilder.Append(LocalizedStrings.GetNonEncoded(-1239615092));
            stringBuilder.Append(" ");
            string value = null;

            if (item.Subject != null)
            {
                value = item.ConversationTopic;
            }
            stringBuilder.Append(value);
            stringBuilder.Append("\n");
            return(stringBuilder.ToString());
        }
Example #2
0
        public void Post()
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "EditPostEventHandler.Post");
            PostItem postItem = null;
            bool     flag     = base.IsParameterSet("Id");

            try
            {
                OwaStoreObjectId owaStoreObjectId = base.GetParameter("fId") as OwaStoreObjectId;
                if (owaStoreObjectId == null)
                {
                    throw new OwaInvalidRequestException("FolderID can not be null. ");
                }
                if (flag)
                {
                    postItem = base.GetRequestItem <PostItem>(new PropertyDefinition[0]);
                }
                else
                {
                    postItem = Utilities.CreateItem <PostItem>(owaStoreObjectId);
                    if (Globals.ArePerfCountersEnabled)
                    {
                        OwaSingleCounters.ItemsCreated.Increment();
                    }
                }
                ExTraceGlobals.MailTracer.TraceDebug((long)this.GetHashCode(), "EditPostEventHandler::Post");
                object parameter = base.GetParameter("Subj");
                if (parameter != null)
                {
                    string subject = (string)parameter;
                    try
                    {
                        postItem.Subject = subject;
                        string text  = postItem.TryGetProperty(ItemSchema.ConversationTopic) as string;
                        bool   flag2 = text == null;
                        if (!flag || flag2)
                        {
                            postItem.ConversationTopic = postItem.Subject;
                        }
                    }
                    catch (PropertyValidationException ex)
                    {
                        throw new OwaInvalidRequestException(ex.Message, ex);
                    }
                }
                parameter = base.GetParameter("Imp");
                if (parameter != null)
                {
                    postItem.Importance = (Importance)parameter;
                }
                parameter = base.GetParameter("Body");
                object parameter2 = base.GetParameter("Text");
                if (parameter != null && parameter2 != null)
                {
                    Markup markup = ((bool)parameter2) ? Markup.PlainText : Markup.Html;
                    BodyConversionUtilities.SetBody(postItem, (string)parameter, markup, StoreObjectType.Post, base.UserContext);
                }
                postItem[MessageItemSchema.IsDraft] = false;
                Utilities.SetPostSender(postItem, base.UserContext, owaStoreObjectId.IsPublic);
                Utilities.SaveItem(postItem, flag);
                if (flag)
                {
                    base.MoveItemToDestinationFolderIfInScratchPad(postItem);
                }
            }
            finally
            {
                if (postItem != null)
                {
                    postItem.Dispose();
                    postItem = null;
                }
            }
        }