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