Пример #1
0
        private IEnumerable <ImapMessageRec> GetImapMessageRecsFromResultData(ImapResultData resultData, FetchMessagesFlags fetchFlags)
        {
            IList <string>        messageUids  = resultData.MessageUids;
            IList <ImapMailFlags> messageFlags = resultData.MessageFlags;
            bool flag = messageUids != null && messageUids.Count > 0 && messageFlags != null && messageFlags.Count > 0;

            if (!flag)
            {
                return(new List <ImapMessageRec>(0));
            }
            if (fetchFlags.HasFlag(FetchMessagesFlags.IncludeExtendedData))
            {
                return(ImapExtendedMessageRec.FromImapResultData(this.folder, resultData));
            }
            return(ImapMessageRec.FromImapResultData(resultData));
        }
Пример #2
0
        internal static SyncEmailContext GetSyncEmailContext(ImapClientFolder folder, ImapMessageRec messageRec)
        {
            ArgumentValidator.ThrowIfNull("folder", folder);
            ArgumentValidator.ThrowIfNull("messageRec", messageRec);
            SyncEmailContext result         = default(SyncEmailContext);
            ImapMailFlags    imapMailFlags  = messageRec.ImapMailFlags;
            ImapMailFlags    imapMailFlags2 = folder.SupportedFlags;

            if (folder.DefaultFolderType.Equals(ImapDefaultFolderType.Drafts))
            {
                imapMailFlags  |= ImapMailFlags.Draft;
                imapMailFlags2 |= ImapMailFlags.Draft;
            }
            if (imapMailFlags2.HasFlag(ImapMailFlags.Draft))
            {
                result.IsDraft = new bool?(imapMailFlags.HasFlag(ImapMailFlags.Draft));
            }
            if (imapMailFlags2.HasFlag(ImapMailFlags.Seen))
            {
                result.IsRead = new bool?(imapMailFlags.HasFlag(ImapMailFlags.Seen));
            }
            if (imapMailFlags2.HasFlag(ImapMailFlags.Answered))
            {
                result.ResponseType = new SyncMessageResponseType?(imapMailFlags.HasFlag(ImapMailFlags.Answered) ? SyncMessageResponseType.Replied : SyncMessageResponseType.None);
            }
            ImapExtendedMessageRec imapExtendedMessageRec = messageRec as ImapExtendedMessageRec;

            if (imapExtendedMessageRec != null)
            {
                result.SyncMessageId = imapExtendedMessageRec.MessageId;
            }
            return(result);
        }