public static void CreatePostReplyForwardHeader(ReplyForwardConfiguration configuration, Item item, ForwardReplyHeaderOptions options, CultureInfo culture) { if (!(item is PostItem)) { throw new ArgumentException("CreatePostReplyForwardheader is called on a non-PostItem item."); } PostItem postItem = (PostItem)item; StringBuilder stringBuilder = new StringBuilder(); bool outputHtml = BodyFormat.TextHtml == configuration.TargetFormat; if (postItem.Sender != null) { if (postItem.From != null && string.Compare(postItem.Sender.DisplayName, postItem.From.DisplayName, StringComparison.Ordinal) != 0) { stringBuilder.Append(string.Format(ClientStrings.OnBehalfOf.ToString(culture), ReplyForwardHeader.GetParticipantDisplayString(postItem.Sender, outputHtml), ReplyForwardHeader.GetParticipantDisplayString(postItem.From, outputHtml))); } else { ReplyForwardHeader.AppendParticipantDisplayString(postItem.Sender, stringBuilder, outputHtml); } } string fromLabel = string.Empty; BodyInjectionFormat bodyPrefixFormat; string bodyPrefix; switch (configuration.TargetFormat) { case BodyFormat.TextPlain: fromLabel = ClientStrings.FromColon.ToString(culture); bodyPrefixFormat = BodyInjectionFormat.Text; bodyPrefix = ReplyForwardHeader.CreatePostTextReplyForwardHeader(postItem, options, fromLabel, stringBuilder.ToString(), culture, configuration.TimeZone); break; case BodyFormat.TextHtml: fromLabel = ClientStrings.FromColon.ToString(culture); bodyPrefixFormat = BodyInjectionFormat.Html; bodyPrefix = ReplyForwardHeader.CreatePostHtmlReplyForwardHeader(postItem, options, fromLabel, stringBuilder.ToString(), culture, configuration.TimeZone); break; default: throw new ArgumentException("Unsupported body format"); } configuration.AddBodyPrefix(bodyPrefix, bodyPrefixFormat); }
public static void CreateForwardReplyHeader(ReplyForwardConfiguration configuration, Item item, ForwardReplyHeaderOptions headerOptions = null) { if (!(item is MessageItem) && !(item is CalendarItemBase) && !(item is PostItem)) { throw new ArgumentException("HTML reply forward headers can only be created for MessageItem, CalendarItemBase and PostItem"); } if (headerOptions == null) { headerOptions = new ForwardReplyHeaderOptions(); } CultureInfo cultureInfo = configuration.Culture ?? item.Session.InternalCulture; if (item is PostItem) { ReplyForwardHeader.CreatePostReplyForwardHeader(configuration, item, headerOptions, cultureInfo); } IList <IRecipientBase> toRecipients = null; IList <IRecipientBase> ccRecipients = null; string from = string.Empty; string sender = null; string fromLabel = ClientStrings.FromColon.ToString(cultureInfo); string toLabel = ClientStrings.ToColon.ToString(cultureInfo); string ccLabel = ClientStrings.CcColon.ToString(cultureInfo); bool isMeetingItem = ObjectClass.IsMeetingMessage(item.ClassName); if (item is MessageItem) { MessageItem messageItem = (MessageItem)item; if (messageItem.From != null) { from = messageItem.From.DisplayName; } if (messageItem.Sender != null) { sender = messageItem.Sender.DisplayName; } toRecipients = ReplyForwardHeader.GetMessageRecipientCollection(RecipientItemType.To, messageItem); ccRecipients = ReplyForwardHeader.GetMessageRecipientCollection(RecipientItemType.Cc, messageItem); } else if (item is CalendarItemBase) { CalendarItemBase calendarItemBase = (CalendarItemBase)item; if (calendarItemBase.Organizer != null) { from = calendarItemBase.Organizer.DisplayName; } toRecipients = ReplyForwardHeader.GetCalendarItemRecipientCollection(AttendeeType.Required, calendarItemBase); ccRecipients = ReplyForwardHeader.GetCalendarItemRecipientCollection(AttendeeType.Optional, calendarItemBase); } BodyInjectionFormat bodyPrefixFormat; string bodyPrefix; switch (configuration.TargetFormat) { case BodyFormat.TextPlain: bodyPrefixFormat = BodyInjectionFormat.Text; bodyPrefix = ReplyForwardHeader.CreateTextReplyForwardHeader(item, headerOptions, fromLabel, from, sender, toLabel, ccLabel, toRecipients, ccRecipients, isMeetingItem, cultureInfo, configuration.TimeZone); break; case BodyFormat.TextHtml: case BodyFormat.ApplicationRtf: bodyPrefixFormat = BodyInjectionFormat.Html; bodyPrefix = ReplyForwardHeader.CreateHtmlReplyForwardHeader(item, headerOptions, fromLabel, from, sender, toLabel, ccLabel, toRecipients, ccRecipients, isMeetingItem, cultureInfo, configuration.TimeZone); break; default: throw new ArgumentException("Unsupported body format"); } configuration.AddBodyPrefix(bodyPrefix, bodyPrefixFormat); }