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); }
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; } } }