Пример #1
0
        public DocumentVersion(IDataReader reader)
            : this()
        {
            VersionId = reader.GetInt64(0);
            DocumentId = reader.GetInt64(1);
            MessageId = reader.ReadInt64OrNull(2);

            Filename = reader.GetString(3);

            SourceChannelId = reader.GetInt64(4);
            TargetChannelId = reader.GetInt64(5);

            From = new SourceAddress(reader.GetString(6));
            To = new SourceAddressCollection(reader.GetString(7));

            StreamName = reader.GetString(8);
            Crc32 = reader.GetString(9);
            Size = reader.GetInt32(10);

            DateReceived = reader.ReadDateTimeOrNull(11);
            DateSent = reader.ReadDateTimeOrNull(12);

            DateCreated = reader.ReadDateTimeOrNull(13);
            DateModified = reader.ReadDateTimeOrNull(14);
        }
Пример #2
0
 public ChannelMessage()
 {
     To = new SourceAddressCollection();
     CC = new SourceAddressCollection();
     BCC = new SourceAddressCollection();
     Metadata = new ChannelMetadata();
     Attachments = new List<ChannelAttachment>();
 }
Пример #3
0
        public void Execute()
        {
            var sourceaddresses =
                new SourceAddressCollection()
                .AddRange(message.To)
                .AddRange(message.CC)
                .AddRange(message.BCC);

            // Try to match every source address to a profile
            foreach (var address in sourceaddresses)
                ProcessSourceAddress(address);

            ProcessSourceAddress(message.From);
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            SourceAddressCollection collection = new SourceAddressCollection();

            if (value == null)
                return collection;

            if (String.IsNullOrEmpty(value.ToString()))
                return collection;

            string[] parts = value.ToString().Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length > 0)
            {
                foreach (var part in parts)
                    collection.Add(new SourceAddress(part.Trim()));
            }

            return collection;
        }
Пример #5
0
        public Message()
        {
            MessageKey = Guid.NewGuid().GetHash();
            Metadata = new ChannelMetadata();
            DateCreated = DateTime.Now;

            To = new SourceAddressCollection();
            CC = new SourceAddressCollection();
            BCC = new SourceAddressCollection();

            SourceChannelId = 0;
            TargetChannelId = 0;

            Documents = new AdvancedObservableCollection<Document>();
            LabelsList = new AdvancedObservableCollection<Label>();

            ReceiveLabels = new List<Label>();
            PostLabels = new List<Label>();
            ContentSynced = true;
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(String.Empty);
            }

            SourceAddressCollection collection = (SourceAddressCollection)value;

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < collection.Count; i++)
            {
                sb.Append(collection[i].ToString());

                if (i < collection.Count - 1)
                {
                    sb.Append("; ");
                }
            }

            return(sb.ToString());
        }
Пример #7
0
        public DocumentVersion(IDataReader reader) : this()
        {
            VersionId  = reader.GetInt64(0);
            DocumentId = reader.GetInt64(1);
            MessageId  = reader.ReadInt64OrNull(2);

            Filename = reader.GetString(3);

            SourceChannelId = reader.GetInt64(4);
            TargetChannelId = reader.GetInt64(5);

            From = new SourceAddress(reader.GetString(6));
            To   = new SourceAddressCollection(reader.GetString(7));

            StreamName = reader.GetString(8);
            Crc32      = reader.GetString(9);
            Size       = reader.GetInt32(10);

            DateReceived = reader.ReadDateTimeOrNull(11);
            DateSent     = reader.ReadDateTimeOrNull(12);

            DateCreated  = reader.ReadDateTimeOrNull(13);
            DateModified = reader.ReadDateTimeOrNull(14);
        }
Пример #8
0
        /// <summary>
        /// Matches the conversation on the the subject field.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="conversation">The conversation.</param>
        /// <returns></returns>
        ExecutionResult MatchOnSubject(Message message, out Conversation conversation)
        {
            if (message.MessageFolder == Folders.SentItems)
            {
                Logger.Debug("MatchOnSubject: Message {0} is a sent item. Creating new conversation because it is not a reply but a new message", LogSource.MessageMatcher, message);

                conversation = CreateNewConversation(message);

                return(ExecutionResult.Break);
            }

            if (message.MessageFolder == Folders.Drafts)
            {
                Logger.Debug("MatchOnSubject: Message {0} is a concept message. Creating new conversation", LogSource.MessageMatcher, message);

                conversation = CreateNewConversation(message);

                return(ExecutionResult.Break);
            }

            if (String.IsNullOrEmpty(message.Context) || String.IsNullOrEmpty(message.Context.ToClearSubject()) || message.Context.Trim().Length == 0)
            {
                Logger.Debug("MatchOnSubject: Message {0} has an empty context. Creating new conversation", LogSource.MessageMatcher, message);

                conversation = CreateNewConversation(message);

                return(ExecutionResult.Break);
            }

            Logger.Debug("MatchOnSubject: trying to find conversation for Message {0} with Context {1}", LogSource.MessageMatcher, message, message.Context.ToClearSubject());

            string context = message.Context.ToClearSubject();

            // Determine if the recipients in the message match with the current recipients
            List <Message> messagesWithSameContext;

            using (mailbox.Messages.ReaderLock)
                messagesWithSameContext = mailbox.Messages.Where(
                    m => m.MessageId != message.MessageId && (m.Context == context || m.Context.ToClearSubject() == context))
                                          .ToList();

            string conversationId = null;

            var recentRelatedMessage = messagesWithSameContext.Where(m => DateTime.Compare((m.SortDate).AddDays(3), DateTime.Now) >= 0).FirstOrDefault();

            if (recentRelatedMessage != null)
            {
                conversationId = recentRelatedMessage.ConversationIdentifier;
            }
            else
            {
                if (message.MessageFolder == Folders.Inbox)
                {
                    if (messagesWithSameContext.Count > 0)
                    {
                        // This is an incoming message
                        SourceAddress from           = message.From;
                        bool          isEmailChannel = SourceAddress.IsValidEmail(from.Address);

                        //Get all channels for user
                        var addresses = ChannelsManager
                                        .Channels
                                        .Where(c => c.InputChannel != null)
                                        .Select(c => c.InputChannel.SourceAdress)
                                        .ToList();

                        foreach (var contextMessage in messagesWithSameContext)
                        {
                            var addressCollection = new SourceAddressCollection();
                            addressCollection.AddRange(contextMessage.To);
                            addressCollection.AddRange(contextMessage.CC);
                            addressCollection.AddRange(contextMessage.BCC);
                            addressCollection.Add(contextMessage.From);

                            if (addressCollection.Contains(from, new SourceAddressComparer()))
                            {
                                bool hasMatchedConversation = false;

                                if (message.To.Count(
                                        c => addresses.Contains(c.Address) || addressCollection.Contains(c)) > 0)
                                {
                                    hasMatchedConversation = true;
                                }

                                if (!hasMatchedConversation && !isEmailChannel)
                                {
                                    if (message.To.Count(addressCollection.Contains) > 0)
                                    {
                                        hasMatchedConversation = true;
                                    }
                                }

                                if (hasMatchedConversation)
                                {
                                    conversationId = contextMessage.ConversationIdentifier;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            if (String.IsNullOrEmpty(conversationId))
            {
                Logger.Debug("MatchOnSubject: Message {0} has no matching conversation, creating a new one", LogSource.MessageMatcher, message);

                // Nothing found, create new conversation
                conversation = CreateNewConversation(message);
            }
            else
            {
                using (mailbox.Conversations.ReaderLock)
                    conversation = mailbox.Conversations.FirstOrDefault(c => c.ConversationIdentifier == conversationId);

                Logger.Debug("MatchOnSubject: Message {0} has matching conversation with ConversationId {1}", LogSource.MessageMatcher, message, conversation.ConversationId);

                UpdateMessage(message, conversation);

                Logger.Debug("MatchOnSubject: Message {0} now has ConversationId {1}", LogSource.MessageMatcher, message, message.ConversationIdentifier);
            }

            // End of line
            return(ExecutionResult.Break);
        }
Пример #9
0
 public Recipients()
 {
     To  = new SourceAddressCollection();
     CC  = new SourceAddressCollection();
     BCC = new SourceAddressCollection();
 }
        void Send_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ClientStats.LogEvent("Quick reply all send");

            if (String.IsNullOrEmpty(QuickReplyAll.Text.Trim()))
                return;

            var newMessage = new Message();

            #region Create message

            var channel = message.SourceChannelId == 0 ?
                ChannelsManager.GetDefaultChannel() :
                ChannelsManager.GetChannelObject(Message.SourceChannelId);

            var recipients = new SourceAddressCollection();
            var sourceAddress = channel.InputChannel.GetSourceAddress();

            recipients.Add(Message.From);
            recipients.AddRange(Message.To);

            // Remove our own address from recipient list
            if (recipients.Contains(sourceAddress))
                recipients.Remove(sourceAddress);

            newMessage.InReplyTo = Message.MessageIdentifier;
            newMessage.ConversationIdentifier = Message.ConversationIdentifier;
            newMessage.Context = "Re: " + Message.Context;
            newMessage.From = channel.InputChannel.GetSourceAddress();
            newMessage.TargetChannelId = channel.Configuration.ChannelId;
            newMessage.To.AddRange(recipients);
            newMessage.CC.AddRange(Message.CC);

            var access = new ClientMessageAccess(newMessage, null,
                MessageBodyGenerator.CreateBodyTextForReply(Message, QuickReplyAll.Text.Nl2Br()));

            newMessage.BodyHtmlStreamName = access.WriteBodyHtml();
            newMessage.BodyPreview = access.GetBodyPreview();
            newMessage.IsRead = true;
            newMessage.DateSent = DateTime.Now;
            newMessage.MessageFolder = Folders.SentItems;
            newMessage.DateSent = DateTime.Now;
            newMessage.DateCreated = DateTime.Now;

            #endregion

            #region Send message

            ClientState.Current.DataService.Save(newMessage);

            // Add message to mailbox
            EventBroker.Publish(AppEvents.MessageStored, newMessage);

            // Save command
            CommandQueue.Enqueue(AppCommands.SendMessage, newMessage);

            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                ClientState.Current.ShowMessage(
                    new AppMessage(Strings.MessageWillBeSentLater)
                        {
                            EntityId = newMessage.MessageId.Value,
                            EntityType = EntityType.Message
                        }, MessageType.Success);
            }

            QuickReplyAll.Text = String.Empty;

            message.TrackAction(ActionType.ReplyForward);

            #endregion
        }
Пример #11
0
 public Recipients()
 {
     To = new SourceAddressCollection();
     CC = new SourceAddressCollection();
     BCC = new SourceAddressCollection();
 }
Пример #12
0
        public Message(IDataReader reader) : this()
        {
            MessageId = reader.GetInt64(0);

            if (!reader.IsDBNull(1))
            {
                MessageKey = reader.GetString(1);
            }

            if (!reader.IsDBNull(2))
            {
                MessageNumber = reader.GetString(2);
            }

            if (!reader.IsDBNull(3))
            {
                MessageIdentifier = reader.GetString(3);
            }

            if (!reader.IsDBNull(4))
            {
                InReplyTo = reader.GetString(4);
            }

            if (!reader.IsDBNull(5))
            {
                SourceFolder = reader.GetString(5);
            }

            if (!reader.IsDBNull(6))
            {
                Size = reader.GetInt64(6);
            }

            if (!reader.IsDBNull(7))
            {
                ConversationIdentifier = reader.GetString(7);
            }

            if (!reader.IsDBNull(8))
            {
                SourceChannelId = reader.GetInt64(8);
            }

            if (!reader.IsDBNull(9))
            {
                TargetChannelId = reader.GetInt64(9);
            }

            if (!reader.IsDBNull(10))
            {
                MessageFolder = reader.GetInt32(10);
            }

            if (!reader.IsDBNull(11))
            {
                From = new SourceAddress(reader.GetString(11));
            }

            if (!reader.IsDBNull(12))
            {
                ReturnTo = new SourceAddress(reader.GetString(12));
            }

            if (!reader.IsDBNull(13))
            {
                To = new SourceAddressCollection(reader.GetString(13));
            }

            if (!reader.IsDBNull(14))
            {
                CC = new SourceAddressCollection(reader.GetString(14));
            }

            if (!reader.IsDBNull(15))
            {
                BCC = new SourceAddressCollection(reader.GetString(15));
            }

            if (!reader.IsDBNull(16))
            {
                Context = reader.GetString(16);
            }

            if (!reader.IsDBNull(17))
            {
                BodyTextStreamName = reader.ReadGuidOrNull(17);
            }

            if (!reader.IsDBNull(18))
            {
                BodyHtmlStreamName = reader.ReadGuidOrNull(18);
            }

            if (!reader.IsDBNull(19))
            {
                Labels = reader.GetString(19);
            }

            if (!reader.IsDBNull(20))
            {
                SendLabels = reader.GetString(20);
            }

            if (!reader.IsDBNull(21))
            {
                IsRead = reader.ReadBoolean(21);
            }

            if (!reader.IsDBNull(22))
            {
                IsStarred = reader.ReadBoolean(22);
            }

            if (!reader.IsDBNull(23))
            {
                var str = reader.GetString(23);

                if (!String.IsNullOrEmpty(str))
                {
                    TargetMessageState = (EntityStates)Enum.Parse(typeof(EntityStates), str);
                }
            }

            if (!reader.IsDBNull(24))
            {
                DateRead = reader.ReadDateTimeOrNull(24);
            }

            if (!reader.IsDBNull(25))
            {
                DateAction = reader.ReadDateTimeOrNull(25);
            }

            if (!reader.IsDBNull(26))
            {
                DateReply = reader.ReadDateTimeOrNull(26);
            }

            if (!reader.IsDBNull(27))
            {
                DateReceived = reader.ReadDateTimeOrNull(27);
            }

            if (!reader.IsDBNull(28))
            {
                DateSent = reader.ReadDateTimeOrNull(28);
            }
        }
Пример #13
0
        void Send_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ClientStats.LogEvent("Quick reply all send");

            if (String.IsNullOrEmpty(QuickReplyAll.Text.Trim()))
            {
                return;
            }

            var newMessage = new Message();

            #region Create message

            var channel = message.SourceChannelId == 0 ?
                          ChannelsManager.GetDefaultChannel() :
                          ChannelsManager.GetChannelObject(Message.SourceChannelId);

            var recipients    = new SourceAddressCollection();
            var sourceAddress = channel.InputChannel.GetSourceAddress();

            recipients.Add(Message.From);
            recipients.AddRange(Message.To);

            // Remove our own address from recipient list
            if (recipients.Contains(sourceAddress))
            {
                recipients.Remove(sourceAddress);
            }

            newMessage.InReplyTo = Message.MessageIdentifier;
            newMessage.ConversationIdentifier = Message.ConversationIdentifier;
            newMessage.Context         = "Re: " + Message.Context;
            newMessage.From            = channel.InputChannel.GetSourceAddress();
            newMessage.TargetChannelId = channel.Configuration.ChannelId;
            newMessage.To.AddRange(recipients);
            newMessage.CC.AddRange(Message.CC);

            var access = new ClientMessageAccess(newMessage, null,
                                                 MessageBodyGenerator.CreateBodyTextForReply(Message, QuickReplyAll.Text.Nl2Br()));

            newMessage.BodyHtmlStreamName = access.WriteBodyHtml();
            newMessage.BodyPreview        = access.GetBodyPreview();
            newMessage.IsRead             = true;
            newMessage.DateSent           = DateTime.Now;
            newMessage.MessageFolder      = Folders.SentItems;
            newMessage.DateSent           = DateTime.Now;
            newMessage.DateCreated        = DateTime.Now;

            #endregion

            #region Send message

            ClientState.Current.DataService.Save(newMessage);

            // Add message to mailbox
            EventBroker.Publish(AppEvents.MessageStored, newMessage);

            // Save command
            CommandQueue.Enqueue(AppCommands.SendMessage, newMessage);

            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                ClientState.Current.ShowMessage(
                    new AppMessage(Strings.MessageWillBeSentLater)
                {
                    EntityId   = newMessage.MessageId.Value,
                    EntityType = EntityType.Message
                }, MessageType.Success);
            }

            QuickReplyAll.Text = String.Empty;

            message.TrackAction(ActionType.ReplyForward);

            #endregion
        }
Пример #14
0
        public static void ReplyAll(Message source, string text)
        {
            var recipients = new SourceAddressCollection();
            recipients.AddRange(source.To);
            recipients.AddRange(source.CC);

            long channelid;

            // Remove receivers own address from list
            if (source.SourceChannelId != 0)
            {
                var channel = ChannelsManager.GetChannelObject(source.SourceChannelId);
                var sourceAddress = channel.InputChannel.GetSourceAddress();

                if (recipients.Contains(sourceAddress))
                    recipients.Remove(sourceAddress);

                channelid = source.SourceChannelId;
            }
            else
            {
                var channel = ChannelsManager.GetChannelObject(source.TargetChannelId);
                var sourceAddress = channel.InputChannel.GetSourceAddress();

                if (recipients.Contains(sourceAddress))
                    recipients.Remove(sourceAddress);

                channelid = source.TargetChannelId;
            }

            ClientState.Current.ViewController.MoveTo(
                PluginsManager.Current.GetPlugin<ConversationsPlugin>().NewItemView,
                new NewMessageDataHelper
                    {
                        SourceMessageId = source.MessageId,
                        SelectedChannelId = channelid,
                        Context = "Re: " + source.Context,
                        To = source.From.ToList(),
                        Cc = recipients,
                        Body = MessageBodyGenerator.CreateBodyTextForReply(source, text),
                        SuppressSignature = !String.IsNullOrEmpty(text)
                    });
        }
Пример #15
0
        /// <summary>
        /// Matches the conversation on the the subject field.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="conversation">The conversation.</param>
        /// <returns></returns>
        ExecutionResult MatchOnSubject(Message message, out Conversation conversation)
        {
            if (message.MessageFolder == Folders.SentItems)
            {
                Logger.Debug("MatchOnSubject: Message {0} is a sent item. Creating new conversation because it is not a reply but a new message", LogSource.MessageMatcher, message);

                conversation = CreateNewConversation(message);

                return ExecutionResult.Break;
            }

            if (message.MessageFolder == Folders.Drafts)
            {
                Logger.Debug("MatchOnSubject: Message {0} is a concept message. Creating new conversation", LogSource.MessageMatcher, message);

                conversation = CreateNewConversation(message);

                return ExecutionResult.Break;
            }

            if (String.IsNullOrEmpty(message.Context) || String.IsNullOrEmpty(message.Context.ToClearSubject()) || message.Context.Trim().Length == 0)
            {
                Logger.Debug("MatchOnSubject: Message {0} has an empty context. Creating new conversation", LogSource.MessageMatcher, message);

                conversation = CreateNewConversation(message);

                return ExecutionResult.Break;
            }

            Logger.Debug("MatchOnSubject: trying to find conversation for Message {0} with Context {1}", LogSource.MessageMatcher, message, message.Context.ToClearSubject());

            string context = message.Context.ToClearSubject();

            // Determine if the recipients in the message match with the current recipients
            List<Message> messagesWithSameContext;

            using (mailbox.Messages.ReaderLock)
                messagesWithSameContext = mailbox.Messages.Where(
                    m => m.MessageId != message.MessageId && (m.Context == context || m.Context.ToClearSubject() == context))
                    .ToList();

            string conversationId = null;

            var recentRelatedMessage = messagesWithSameContext.Where(m => DateTime.Compare((m.SortDate).AddDays(3), DateTime.Now) >= 0).FirstOrDefault();

            if (recentRelatedMessage != null)
            {
                conversationId = recentRelatedMessage.ConversationIdentifier;
            }
            else
            {
                if (message.MessageFolder == Folders.Inbox)
                {
                    if (messagesWithSameContext.Count > 0)
                    {
                        // This is an incoming message
                        SourceAddress from = message.From;
                        bool isEmailChannel = SourceAddress.IsValidEmail(from.Address);

                        //Get all channels for user
                        var addresses = ChannelsManager
                            .Channels
                            .Where(c => c.InputChannel != null)
                            .Select(c => c.InputChannel.SourceAdress)
                            .ToList();

                        foreach (var contextMessage in messagesWithSameContext)
                        {
                            var addressCollection = new SourceAddressCollection();
                            addressCollection.AddRange(contextMessage.To);
                            addressCollection.AddRange(contextMessage.CC);
                            addressCollection.AddRange(contextMessage.BCC);
                            addressCollection.Add(contextMessage.From);

                            if (addressCollection.Contains(from, new SourceAddressComparer()))
                            {
                                bool hasMatchedConversation = false;

                                if (message.To.Count(
                                        c => addresses.Contains(c.Address) || addressCollection.Contains(c)) > 0)
                                    hasMatchedConversation = true;

                                if (!hasMatchedConversation && !isEmailChannel)
                                {
                                    if (message.To.Count(addressCollection.Contains) > 0)
                                        hasMatchedConversation = true;
                                }

                                if (hasMatchedConversation)
                                {
                                    conversationId = contextMessage.ConversationIdentifier;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            if (String.IsNullOrEmpty(conversationId))
            {
                Logger.Debug("MatchOnSubject: Message {0} has no matching conversation, creating a new one", LogSource.MessageMatcher, message);

                // Nothing found, create new conversation
                conversation = CreateNewConversation(message);
            }
            else
            {
                using (mailbox.Conversations.ReaderLock)
                    conversation = mailbox.Conversations.FirstOrDefault(c => c.ConversationIdentifier == conversationId);

                Logger.Debug("MatchOnSubject: Message {0} has matching conversation with ConversationId {1}", LogSource.MessageMatcher, message, conversation.ConversationId);

                UpdateMessage(message, conversation);

                Logger.Debug("MatchOnSubject: Message {0} now has ConversationId {1}", LogSource.MessageMatcher, message, message.ConversationIdentifier);
            }

            // End of line
            return ExecutionResult.Break;
        }
Пример #16
0
        public Message(IDataReader reader)
            : this()
        {
            MessageId = reader.GetInt64(0);

            if (!reader.IsDBNull(1))
                MessageKey = reader.GetString(1);

            if (!reader.IsDBNull(2))
                MessageNumber = reader.GetString(2);

            if (!reader.IsDBNull(3))
                MessageIdentifier = reader.GetString(3);

            if (!reader.IsDBNull(4))
                InReplyTo = reader.GetString(4);

            if (!reader.IsDBNull(5))
                SourceFolder = reader.GetString(5);

            if (!reader.IsDBNull(6))
                Size = reader.GetInt64(6);

            if (!reader.IsDBNull(7))
                ConversationIdentifier = reader.GetString(7);

            if (!reader.IsDBNull(8))
                SourceChannelId = reader.GetInt64(8);

            if (!reader.IsDBNull(9))
                TargetChannelId = reader.GetInt64(9);

            if (!reader.IsDBNull(10))
                MessageFolder = reader.GetInt32(10);

            if (!reader.IsDBNull(11))
                From = new SourceAddress(reader.GetString(11));

            if (!reader.IsDBNull(12))
                ReturnTo = new SourceAddress(reader.GetString(12));

            if (!reader.IsDBNull(13))
                To = new SourceAddressCollection(reader.GetString(13));

            if (!reader.IsDBNull(14))
                CC = new SourceAddressCollection(reader.GetString(14));

            if (!reader.IsDBNull(15))
                BCC = new SourceAddressCollection(reader.GetString(15));

            if (!reader.IsDBNull(16))
                Context = reader.GetString(16);

            if (!reader.IsDBNull(17))
                BodyTextStreamName = reader.ReadGuidOrNull(17);

            if (!reader.IsDBNull(18))
                BodyHtmlStreamName = reader.ReadGuidOrNull(18);

            if (!reader.IsDBNull(19))
                Labels = reader.GetString(19);

            if (!reader.IsDBNull(20))
                SendLabels = reader.GetString(20);

            if (!reader.IsDBNull(21))
                IsRead = reader.ReadBoolean(21);

            if (!reader.IsDBNull(22))
                IsStarred = reader.ReadBoolean(22);

            if (!reader.IsDBNull(23))
            {
                var str = reader.GetString(23);

                if (!String.IsNullOrEmpty(str))
                    TargetMessageState = (EntityStates)Enum.Parse(typeof(EntityStates), str);
            }

            if (!reader.IsDBNull(24))
                DateRead = reader.ReadDateTimeOrNull(24);

            if (!reader.IsDBNull(25))
                DateAction = reader.ReadDateTimeOrNull(25);

            if (!reader.IsDBNull(26))
                DateReply = reader.ReadDateTimeOrNull(26);

            if (!reader.IsDBNull(27))
                DateReceived = reader.ReadDateTimeOrNull(27);

            if (!reader.IsDBNull(28))
                DateSent = reader.ReadDateTimeOrNull(28);
        }
Пример #17
0
        public static NewMessageDataHelper Parse(string mailtoString)
        {
            var uri = new Uri(mailtoString);

            var to = new SourceAddress(String.Format("{0}@{1}", uri.UserInfo, uri.DnsSafeHost));
            var cc = new SourceAddressCollection();
            var bcc = new SourceAddressCollection();
            var subject = String.Empty;
            var body = String.Empty;

            // See if there is a subject embedded in the url
            if (uri.Query.Length > 0)
            {
                var parts = NameValueParser.GetCollection(uri.Query, "?", "&");

                if (parts["subject"] != null)
                    subject = parts["subject"];

                if (parts["body"] != null)
                    body = parts["body"];

                if (parts["cc"] != null)
                    cc = new SourceAddressCollection(parts["cc"]);

                if (parts["bcc"] != null)
                    bcc = new SourceAddressCollection(parts["bcc"]);
            }

            return new NewMessageDataHelper { Context = subject, To = to.ToList(), Cc = cc, Bcc = bcc, Body = body };
        }
Пример #18
0
        public SourceAddressCollection GetConversationMembers()
        {
            var recipients = new SourceAddressCollection();
            var comparer = new MailAddressEqualityComparer();

            foreach (var message in Messages)
            {
                if (!recipients.Contains(message.From, comparer))
                    recipients.Add(message.From);

                foreach (var address in message.To)
                {
                    if (!recipients.Contains(address, comparer))
                        recipients.Add(address);
                }

                foreach (var address in message.CC)
                {
                    if (!recipients.Contains(address, comparer))
                        recipients.Add(address);
                }

                foreach (var address in message.BCC)
                {
                    if (!recipients.Contains(address, comparer))
                        recipients.Add(address);
                }
            }

            return recipients;
        }