Beispiel #1
0
        internal static string GetParticipantDisplayString(Participant participant, bool outputHtml)
        {
            if (participant == null)
            {
                throw new ArgumentNullException("participant");
            }
            StringBuilder stringBuilder = new StringBuilder();

            ReplyForwardUtilities.AppendParticipantDisplayString(participant, stringBuilder, outputHtml);
            return(stringBuilder.ToString());
        }
Beispiel #2
0
        private static string CreatePostReplyForwardHeader(BodyFormat bodyFormat, Item item, UserContext userContext, string postToFolderName)
        {
            PostItem postItem = item as PostItem;

            if (postItem == null)
            {
                throw new ArgumentException("OWA logic error . CreatePostReplyForwardheader is called on a non-PostItem item.");
            }
            if (postToFolderName == null)
            {
                throw new ArgumentNullException("postToFolderName");
            }
            if (string.Empty == postToFolderName)
            {
                throw new ArgumentException("postToFolderName should not be empty. ");
            }
            StringBuilder stringBuilder = new StringBuilder();
            bool          outputHtml    = BodyFormat.TextHtml == bodyFormat;

            if (postItem.Sender != null)
            {
                if (Utilities.IsOnBehalfOf(postItem.Sender, postItem.From))
                {
                    stringBuilder.Append(string.Format(LocalizedStrings.GetHtmlEncoded(-1426120402), ReplyForwardUtilities.GetParticipantDisplayString(postItem.Sender, outputHtml), ReplyForwardUtilities.GetParticipantDisplayString(postItem.From, outputHtml)));
                }
                else
                {
                    ReplyForwardUtilities.AppendParticipantDisplayString(postItem.Sender, stringBuilder, outputHtml);
                }
            }
            string fromLabel = string.Empty;

            switch (bodyFormat)
            {
            case BodyFormat.TextPlain:
                fromLabel = LocalizedStrings.GetNonEncoded(-1376223345);
                return(ReplyForwardUtilities.CreatePostTextReplyForwardHeader(postItem, userContext, fromLabel, stringBuilder.ToString(), postToFolderName));

            case BodyFormat.TextHtml:
                fromLabel = LocalizedStrings.GetHtmlEncoded(-1376223345);
                return(ReplyForwardUtilities.CreatePostHtmlReplyForwardHeader(postItem, userContext, fromLabel, stringBuilder.ToString(), postToFolderName));

            default:
                throw new ArgumentException("Unsupported body format");
            }
        }
Beispiel #3
0
        internal static string CreateReplyForwardHeader(BodyFormat bodyFormat, Item item, UserContext userContext, StoreObjectId parentFolderId)
        {
            MessageItem      messageItem      = item as MessageItem;
            PostItem         postItem         = item as PostItem;
            CalendarItemBase calendarItemBase = item as CalendarItemBase;

            if (messageItem == null && calendarItemBase == null && postItem == null)
            {
                throw new ArgumentException("HTML reply forward headers can only be created for MessageItem and CalendarItemBase or PostItem. ");
            }
            if (postItem != null)
            {
                if (parentFolderId == null)
                {
                    throw new ArgumentNullException("parentFolderId");
                }
                string parentFolderName = Utilities.GetParentFolderName(item, parentFolderId, userContext);
                return(ReplyForwardUtilities.CreatePostReplyForwardHeader(bodyFormat, item, userContext, parentFolderName));
            }
            else
            {
                IList <IRecipientBase> toRecipients = null;
                IList <IRecipientBase> ccRecipients = null;
                string        fromLabel             = string.Empty;
                StringBuilder stringBuilder         = new StringBuilder();
                string        toLabel = string.Empty;
                string        ccLabel = string.Empty;
                bool          flag    = bodyFormat == BodyFormat.TextHtml;
                if (messageItem != null)
                {
                    fromLabel = (flag ? LocalizedStrings.GetHtmlEncoded(-1376223345) : LocalizedStrings.GetNonEncoded(-1376223345));
                    if (messageItem.Sender != null)
                    {
                        if (Utilities.IsOnBehalfOf(messageItem.Sender, messageItem.From))
                        {
                            stringBuilder.Append(string.Format(LocalizedStrings.GetHtmlEncoded(-1426120402), ReplyForwardUtilities.GetParticipantDisplayString(messageItem.Sender, flag), ReplyForwardUtilities.GetParticipantDisplayString(messageItem.From, flag)));
                        }
                        else
                        {
                            ReplyForwardUtilities.AppendParticipantDisplayString(messageItem.Sender, stringBuilder, flag);
                        }
                    }
                    toLabel      = (flag ? LocalizedStrings.GetHtmlEncoded(-829627742) : LocalizedStrings.GetNonEncoded(-829627742));
                    ccLabel      = (flag ? LocalizedStrings.GetHtmlEncoded(-798075995) : LocalizedStrings.GetNonEncoded(-798075995));
                    toRecipients = ReplyForwardUtilities.GetMessageRecipientCollection(RecipientItemType.To, messageItem);
                    ccRecipients = ReplyForwardUtilities.GetMessageRecipientCollection(RecipientItemType.Cc, messageItem);
                }
                else if (calendarItemBase != null)
                {
                    fromLabel = (flag ? LocalizedStrings.GetHtmlEncoded(-1376223345) : LocalizedStrings.GetNonEncoded(-1376223345));
                    if (calendarItemBase.Organizer != null)
                    {
                        ReplyForwardUtilities.AppendParticipantDisplayString(calendarItemBase.Organizer, stringBuilder, flag);
                    }
                    toLabel      = (flag ? LocalizedStrings.GetHtmlEncoded(-1709254790) : LocalizedStrings.GetNonEncoded(-1709254790));
                    ccLabel      = (flag ? LocalizedStrings.GetHtmlEncoded(-98673561) : LocalizedStrings.GetNonEncoded(-98673561));
                    toRecipients = ReplyForwardUtilities.GetCalendarItemRecipientCollection(AttendeeType.Required, calendarItemBase);
                    ccRecipients = ReplyForwardUtilities.GetCalendarItemRecipientCollection(AttendeeType.Optional, calendarItemBase);
                }
                switch (bodyFormat)
                {
                case BodyFormat.TextPlain:
                    return(ReplyForwardUtilities.CreateTextReplyForwardHeader(item, userContext, fromLabel, stringBuilder.ToString(), toLabel, ccLabel, toRecipients, ccRecipients));

                case BodyFormat.TextHtml:
                    return(ReplyForwardUtilities.CreateHtmlReplyForwardHeader(item, userContext, fromLabel, stringBuilder.ToString(), toLabel, ccLabel, toRecipients, ccRecipients));

                default:
                    throw new ArgumentException("Unsupported body format");
                }
            }
        }