Beispiel #1
0
 private void OnMailAddImpl(MAPINtf ntf)
 {
     if (CheckStorageIgnored(_storeID))
     {
         return;
     }
     ProcessMailAddNtf.DoJob(ntf, _storeID);
 }
Beispiel #2
0
        protected override void Execute()
        {
            if (OutlookSession.OutlookProcessor.ShuttingDown)
            {
                return;
            }

            IEFolder folder = OutlookSession.OpenFolder(_ntf.ParentID, _storeID);

            if (folder != null)
            {
                using ( folder )
                {
                    FolderDescriptor folderDescriptor = FolderDescriptor.Get(folder);
                    if (folderDescriptor == null)
                    {
                        return;
                    }
                    IResource resFolder = Folder.Find(folderDescriptor.FolderIDs.EntryId);
                    if (resFolder == null)
                    {
                        return;
                    }

                    bool ignoredFolder = Folder.IsIgnored(resFolder);

                    IEMessage message = OutlookSession.OpenMessage(_ntf.EntryID, _storeID);
                    if (message == null)
                    {
                        return;
                    }
                    using ( message )
                    {
                        string    entryId = OutlookSession.GetMessageID(message);
                        IResource mail    = Core.ResourceStore.FindUniqueResource("Email", PROP.EntryID, _ntf.EntryID);
                        if (mail == null && _ntf.OldEntryID != null)
                        {
                            mail = Core.ResourceStore.FindUniqueResource("Email", PROP.EntryID, _ntf.OldEntryID);
                        }

                        if (ignoredFolder && mail != null)
                        {
                            Trace.WriteLine("Moved mail ID=" + mail.Id + " to ignored folder");
                            Mail.ForceDelete(mail);
                            return;
                        }
                        if (mail == null)
                        {
                            ProcessMailAddNtf.DoJob(_ntf, _storeID);
                            return;
                        }
                        mail.SetProp(PROP.EntryID, entryId);
                        Folder.LinkMail(resFolder, mail);
                    }
                }
            }
        }
Beispiel #3
0
 private void OnMailModifyImpl(MAPIFullNtf ntf)
 {
     if (CheckStorageIgnored(_storeID))
     {
         return;
     }
     try
     {
         IEFolder folder = OutlookSession.OpenFolder(ntf.ParentID, _storeID);
         if (folder == null)
         {
             return;
         }
         using ( folder )
         {
             FolderDescriptor folderDescriptor = FolderDescriptor.Get(folder);
             if (folderDescriptor.ContainerClass == FolderType.IMAP)
             {
                 if (!ProcessMailAddNtf.ProcessIMAPMessage(folder, ntf.EntryID))
                 {
                     return;
                 }
             }
             IEMessage message = OutlookSession.OpenMessage(ntf.EntryID, _storeID);
             if (message == null)
             {
                 return;
             }
             using ( message )
             {
                 ProcessMailModifyImpl(ntf, message, folderDescriptor);
             }
         }
     }
     catch (System.Threading.ThreadAbortException ex)
     {
         Tracer._TraceException(ex);
     }
     catch (Exception exception)
     {
         Core.ReportBackgroundException(exception);
     }
 }
Beispiel #4
0
        private void OnNewMailImpl(MAPINtf ntf)
        {
            Trace("[New] *Email* - OnNewMailImpl");
            if (CheckStorageIgnored(_storeID))
            {
                Trace("OnNewMailImpl: storage is ignored");
                return;
            }
            FolderDescriptor folderDescriptor = FolderDescriptor.Get(ntf.ParentID, _storeID);

            if (folderDescriptor == null)
            {
                Trace("OnNewMailImpl: folderDescriptor == null");
                return;
            }

            if (folderDescriptor.ContainerClass == FolderType.IMAP)
            {
                IEFolder folder = OutlookSession.OpenFolder(ntf.ParentID, _storeID);
                if (folder == null)
                {
                    return;
                }
                using ( folder )
                {
                    if (!ProcessMailAddNtf.ProcessIMAPMessage(folder, ntf.EntryID))
                    {
                        return;
                    }
                }
            }

            IEMessage message = OutlookSession.OpenMessage(ntf.EntryID, _storeID);

            if (message == null)
            {
                Trace("OnNewMailImpl: cannot open mapi message");
                return;
            }
            using ( message )
            {
                try
                {
                    string entryId = OutlookSession.GetMessageID(message);
                    if (OutlookSession.IsMailExported(entryId))
                    {
                        Trace("OnNewMailImpl: mail is exported at the moment");
                        return;
                    }
                    new NewMailDescriptor(folderDescriptor, entryId, message).QueueJob(JobPriority.AboveNormal);
                }
                catch (System.Threading.ThreadAbortException ex)
                {
                    Tracer._TraceException(ex);
                }
                catch (Exception exception)
                {
                    Core.ReportBackgroundException(exception);
                }
            }
        }