예제 #1
0
파일: MessageActions.cs 프로젝트: mo5h/omeo
        protected override void ExecuteAction(IResource resource, PairIDs pairIDs)
        {
            Tracer._Trace("Execute action: UnDeleteIMAPMessageAction");
            Trace.WriteLine(">>> UnDeleteIMAPMessageAction.ExecuteAction");
            if (pairIDs == null)
            {
                return;
            }

            IResource folder = resource.GetLinkProp(PROP.MAPIFolder);

            if (!Folder.IsIMAPFolder(folder))
            {
                return;
            }
            IEMessage message = OutlookSession.OpenMessage(pairIDs.EntryId, pairIDs.StoreId);

            if (message == null)
            {
                return;
            }
            using ( message )
            {
                int tag = message.GetIDsFromNames(ref GUID.set1, lID.msgDeletedInIMAP, PropType.PT_LONG);
                message.DeleteProp(tag);
                OutlookSession.SaveChanges("Undelete message resource id = " + resource.Id, message, pairIDs.EntryId);
            }
            Trace.WriteLine("<<< UnDeleteIMAPMessageAction.ExecuteAction");
        }
예제 #2
0
        private void OnUnreadItemChangedImpl(IResource emailResource)
        {
            Guard.NullArgument(emailResource, "emailResource");
            if (emailResource.Type != STR.Email)
            {
                return;
            }
            PairIDs messageIDs = PairIDs.Get(emailResource);

            if (messageIDs == null)
            {
                return;
            }

            IResource folder = Mail.GetParentFolder(emailResource);

            if (folder != null && Folder.IsIMAPFolder(folder))
            {
                PairIDs folderIDs = PairIDs.Get(folder);
                if (folderIDs != null)
                {
                    IEFolder mapiFolder = OutlookSession.OpenFolder(folderIDs.EntryId, folderIDs.StoreId);
                    if (mapiFolder != null)
                    {
                        using ( mapiFolder )
                        {
                            try
                            {
                                mapiFolder.SetReadFlags(messageIDs.EntryId, emailResource.HasProp(Core.Props.IsUnread));
                                return;
                            }
                            catch (COMException exception)
                            {
                                if (exception.ErrorCode == (unchecked ((int)0x80040604)))
                                {
                                    StandartJobs.MessageBox("Unspecified error. Can't change unread flag for email.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                Core.ReportException(exception, ExceptionReportFlags.AttachLog);
                            }
                        }
                    }
                }
            }

            IEMessage message = OutlookSession.OpenMessage(messageIDs.EntryId, messageIDs.StoreId);

            if (message != null)
            {
                using ( message )
                {
                    bool unread = emailResource.HasProp(Core.Props.IsUnread);
                    message.SetUnRead(unread);
                    OutlookSession.SaveChanges("Export Read/Unread flag" + emailResource.Id, message, messageIDs.EntryId);
                }
            }
        }
예제 #3
0
파일: MAPIFolder.cs 프로젝트: mo5h/omeo
 public static bool MailInIMAP(IResource resource)
 {
     if (resource.Type == STR.Email)
     {
         IResource folder = GetParentFolder(resource);
         if (folder != null && Folder.IsIMAPFolder(folder))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #4
0
 public static void DeleteMail(IResource mail, PairIDs pairIDs, bool deletedItems)
 {
     if (deletedItems)
     {
         IResource folder = mail.GetLinkProp(PROP.MAPIFolder);
         if (folder != null)
         {
             deletedItems = !Folder.IsIMAPFolder(folder);
         }
     }
     if (pairIDs != null)
     {
         OutlookSession.DeleteMessage(pairIDs.StoreId, pairIDs.EntryId, deletedItems);
     }
     Core.ResourceAP.QueueJob(JobPriority.Immediate, new ResourceDelegate(Mail.Delete), mail);
 }
예제 #5
0
파일: MAPIFolder.cs 프로젝트: mo5h/omeo
        public static void Delete(IResource mail)
        {
            if (mail == null || mail.Id == -1)
            {
                return;
            }
            if (!Mail.CanBeDeleted(mail))
            {
                return;
            }
            IResource folder = mail.GetLinkProp(PROP.MAPIFolder);

            if (folder != null && Folder.IsIMAPFolder(folder) && !Settings.IgnoreDeletedIMAPMessages)
            {
                mail.SetProp(PROP.DeletedInIMAP, true);
                Folder.LinkMail(folder, mail);
            }
            else
            {
                ForceDelete(mail);
            }
        }
예제 #6
0
파일: MessageActions.cs 프로젝트: mo5h/omeo
        protected override bool NeedProcess(IResourceList selectedResources)
        {
            Guard.NullArgument(selectedResources, "selectedResources");
            if (_deletedItems)
            {
                return(true);
            }
            if (selectedResources.Count == 0)
            {
                return(false);
            }
            IResource mail   = selectedResources[0];
            IResource folder = mail.GetLinkProp(PROP.MAPIFolder);

            Guard.NullLocalVariable(folder, "folder");

            if (Folder.IsIMAPFolder(folder))
            {
                _deletedItems = true;
                return(true);
            }

            string strConfirmation = null;

            if (selectedResources.Count == 1)
            {
                strConfirmation = "Are you sure that you want to permanently delete the selected message?";
            }
            else
            {
                strConfirmation = "Are you sure that you want to permanently delete the selected messages?";
            }
            DialogResult result =
                MessageBox.Show(strConfirmation, "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            return(result == DialogResult.Yes);
        }