Esempio n. 1
0
        private static void ProcessFolder(IEFolder folder)
        {
            IETable table = folder.GetEnumTableForOwnEmail();

            if (table == null)
            {
                return;
            }
            using ( table )
            {
                ArrayList ownerEmails = GetOwnerEmails();
                ArrayList ownerNames  = new ArrayList();

                int count = table.GetRowCount();
                if (count > 0)
                {
                    table.Sort(MAPIConst.PR_MESSAGE_DELIVERY_TIME, false);
                }
                for (uint i = 0; i < count; i++)
                {
                    ProcessRow(ownerEmails, ownerNames, table);
                }
                ProcessOwnerEmails(ownerEmails, ownerNames);
            }
        }
Esempio n. 2
0
        private static int GetAttachNum(IEMessage message, int index)
        {
            IETable table = message.GetAttachments();

            if (table == null)
            {
                return(0);
            }
            using ( table )
            {
                int count = table.GetRowCount();
                for (int i = 0; i < count; i++)
                {
                    IERowSet row = table.GetNextRow();
                    if (row != null)
                    {
                        using ( row )
                        {
                            if (index == i)
                            {
                                return(row.FindLongProp(MAPIConst.PR_ATTACH_NUM));
                            }
                        }
                    }
                    if (index < i)
                    {
                        break;
                    }
                }
            }
            return(0);
        }
Esempio n. 3
0
        public static bool ProcessIMAPMessage(IEFolder folder, string entryID)
        {
            Tracer._Trace("ProcessIMAPMessage");
            IETable table = folder.GetEnumTable(DateTime.MinValue);

            if (table == null)
            {
                return(false);
            }
            using ( table )
            {
                int count = table.GetRowCount();
                if (count > 0)
                {
                    table.Sort(MAPIConst.PR_MESSAGE_DELIVERY_TIME, false);
                }
                for (uint i = 0; i < count; i++)
                {
                    IERowSet row = table.GetNextRow();
                    if (row == null)
                    {
                        continue;
                    }
                    using ( row )
                    {
                        if (row.GetBinProp(0) == entryID)
                        {
                            if (row.GetLongProp(6) == 1)
                            {
                                Tracer._Trace("ProcessIMAPMessage FALSE");
                                //folder.SetMessageStatus( entryID, 0x1000, 0x1000 );
                                return(false);
                            }
                            else
                            {
                                Tracer._Trace("ProcessIMAPMessage TRUE");
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 4
0
        private void PrepareRecipients(IEMessage message)
        {
            IETable recips = message.GetRecipients();

            if (recips != null)
            {
                using ( recips )
                {
                    long count = recips.GetRowCount();
                    for (long i = 0; i < count; i++)
                    {
                        IERowSet rowSet = recips.GetNextRow();
                        if (rowSet != null)
                        {
                            using ( rowSet )
                            {
                                string emailAddr = rowSet.FindStringProp(MAPIConst.PR_SMTP_ADDRESS);
                                if (emailAddr == null || emailAddr.Length == 0)
                                {
                                    emailAddr = rowSet.FindStringProp(MAPIConst.PR_EMAIL_ADDRESS);
                                }
                                if (emailAddr != null && emailAddr.Length > 0)
                                {
                                    string displayName = rowSet.FindStringProp(MAPIConst.PR_DISPLAY_NAME);

                                    bool isTo   = (rowSet.FindLongProp(MAPIConst.PR_RECIPIENT_TYPE) == (int)RecipientType.To);
                                    bool mySelf = OwnerEmailDetector.IsOwnerEmail(emailAddr);

                                    if (mySelf)
                                    {
                                        _bSentToMe = true;
                                    }
                                    _recipients.Add(new RecipientHelper(emailAddr, displayName, isTo, mySelf));
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        private static void ProcessRow(ArrayList ownerEmails, ArrayList ownerNames, IETable table)
        {
            IERowSet row = table.GetNextRow();

            if (row == null)
            {
                return;
            }
            using ( row )
            {
                string senderEmail = row.GetStringProp(0);
                string senderName  = row.GetStringProp(1);
                if (senderEmail != null && senderEmail.Length > 0 && ownerEmails.IndexOf(senderEmail) == -1)
                {
                    ownerEmails.Add(senderEmail);
                }
                if (senderName != null && senderName.Length > 0 && ownerNames.IndexOf(senderName) == -1)
                {
                    ownerNames.Add(senderName);
                }
            }
        }
Esempio n. 6
0
            void EnumerateMail(IEFolder mapiFolder)
            {
                IETable table = null;

                try
                {
                    table = mapiFolder.GetEnumTable(DateTime.Now.AddDays(-3));
                }
                catch (System.UnauthorizedAccessException) {}
                if (table == null)
                {
                    return;
                }
                using ( table )
                {
                    int count = table.GetRowCount();
                    if (count > 0)
                    {
                        table.Sort(MAPIConst.PR_MESSAGE_DELIVERY_TIME, false);
                    }
                    for (uint i = 0; i < count; i++)
                    {
                        IERowSet row = table.GetNextRow();
                        if (row == null)
                        {
                            continue;
                        }
                        using ( row )
                        {
                            for (int j = 0; j < 1; ++j)
                            {
                                ProcessRow(row, mapiFolder);
                            }
                        }
                    }
                }
            }
Esempio n. 7
0
        /**
         * Creates resources for the attachments of the specified e-mail
         * and adds them as links to the specified e-mail resource.
         */
        private void PrepareAttachments(IEMessage message)
        {
            // NOTE: IEMessage.GetAttachments() restricts the attachment table to a specific
            // set of columns, so if you need to process more columns here, don't forget to
            // modify the code in GetAttachments().
            IETable attaches = message.GetAttachments();

            if (attaches != null)
            {
                using ( attaches )
                {
                    long count = attaches.GetRowCount();
                    for (long i = 0; i < count; i++)
                    {
                        IERowSet rowSet = attaches.GetNextRow();
                        if (rowSet == null)
                        {
                            continue;
                        }
                        using ( rowSet )
                        {
                            int size         = rowSet.FindLongProp(MAPIConst.PR_ATTACH_SIZE);
                            int attachMethod = rowSet.FindLongProp(MAPIConst.PR_ATTACH_METHOD);

                            string strFileName = rowSet.FindStringProp(MAPIConst.PR_ATTACH_LONG_FILENAME);
                            if (strFileName == null)
                            {
                                strFileName = rowSet.FindStringProp(MAPIConst.PR_ATTACH_FILENAME);
                            }
                            if (strFileName == null)
                            {
                                strFileName = rowSet.FindStringProp(MAPIConst.PR_DISPLAY_NAME);
                            }
                            if (strFileName != null)
                            {
                                string strFileType = string.Empty;
                                int    dotIndex    = strFileName.LastIndexOf(".");
                                if (dotIndex != -1)
                                {
                                    strFileType = strFileName.Substring(dotIndex).ToUpper();
                                }
                                int      num          = rowSet.FindLongProp(MAPIConst.PR_ATTACH_NUM);
                                string   strContentID = null;
                                IEAttach attachment   = message.OpenAttach(num);
                                if (attachment != null)
                                {
                                    using ( attachment )
                                    {
                                        strContentID = attachment.GetStringProp(MAPIConst.PR_ATTACH_CONTENT_ID);
                                    }
                                }

                                AttachmentHelper attach =
                                    new AttachmentHelper(strFileName, strFileType, (int)i, size, attachMethod, strContentID, num);
                                _attachments.Add(attach);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        private void EnumerateMail(FolderDescriptor folder, IEFolder mapiFolder)
        {
            try
            {
                OnFolderFetched(folder.Name);
                int indexed = 0;

                IResource resFolder  = Folder.Find(folder.FolderIDs.EntryId);
                DateTime  dtRestrict = GetRestrictDate(resFolder);

                IETable table = null;
                try
                {
                    table = mapiFolder.GetEnumTable(dtRestrict);
                }
                catch (System.UnauthorizedAccessException exception)
                {
                    _tracer.TraceException(exception);
                }
                catch (OutOfMemoryException exception)
                {
                    _tracer.TraceException(exception);
                }
                if (table == null)
                {
                    return;
                }
                using ( table )
                {
                    int count = table.GetRowCount();
                    if (count > 0)
                    {
                        table.Sort(MAPIConst.PR_MESSAGE_DELIVERY_TIME, false);
                    }
                    for (uint i = 0; i < count; i++)
                    {
                        if (OutlookSession.OutlookProcessor.ShuttingDown)
                        {
                            break;
                        }
                        if (_idle && Settings.IdleModeManager.CheckInterruptIdle())
                        {
                            break;
                        }
                        IERowSet row = row = table.GetNextRow();
                        if (row == null)
                        {
                            continue;
                        }
                        using ( row )
                        {
                            if (row.GetLongProp(6) != 1)
                            {
                                ProcessRow(row, folder, mapiFolder, ref indexed);
                            }
                        }
                    }
                }
                if (Settings.IdleModeManager.CompletedIdle)
                {
                    Folder.SetSeeAllAsync(resFolder);
                }

                _tracer.Trace("Indexed " + indexed + " messages in folder " + folder.Name);
            }
            finally
            {
                OutlookSession.ProcessJobs();
            }
        }