예제 #1
0
        public static void DeleteFolder(PairIDs folderIDs, bool DeletedItems, string newName)
        {
            if (!DeletedItems)
            {
                DeleteFolderImpl(folderIDs, false);
                return;
            }

            PairIDs deletedItems = OutlookSession.GetDeletedItemsFolderIDs(folderIDs.StoreId);

            if (deletedItems == null)
            {
                DeleteFolderImpl(folderIDs, false);
                return;
            }

            string   folderID = null;
            IEFolder folder   = OutlookSession.OpenFolder(folderIDs.EntryId, folderIDs.StoreId);

            if (folder != null)
            {
                using ( folder )
                {
                    folderID = folder.GetFolderID();
                }
            }
            if (folderID != null)
            {
                if (folderID != deletedItems.EntryId)
                {
                    if (newName != null)
                    {
                        IEFolder eFolder = OutlookSession.OpenFolder(folderIDs.EntryId, folderIDs.StoreId);
                        if (eFolder != null)
                        {
                            using ( eFolder )
                            {
                                eFolder.SetStringProp(MAPIConst.PR_DISPLAY_NAME, newName);
                                eFolder.SaveChanges();
                            }
                        }
                    }

                    if (MoveFolder(folderIDs.StoreId, folderIDs.EntryId, folderID, deletedItems))
                    {
                        return;
                    }
                }
            }
            DeleteFolderImpl(folderIDs, false);
        }
예제 #2
0
        public static bool DeleteMessage(string storeId, string entryId, bool DeletedItems)
        {
            if (!DeletedItems)
            {
                OutlookSession.DeleteMessageImpl(storeId, entryId, false);
                return(true);
            }

            PairIDs folderIds = OutlookSession.GetDeletedItemsFolderIDs(storeId);

            if (folderIds == null)
            {
                OutlookSession.DeleteMessageImpl(storeId, entryId, false);
                return(true);
            }

            string    folderID = null;
            IEMessage message  = OutlookSession.OpenMessage(entryId, storeId);

            if (message == null)
            {
                return(false);
            }
            using ( message )
            {
                folderID = message.GetBinProp(MAPIConst.PR_PARENT_ENTRYID);
            }
            if (folderID != null)
            {
                if (folderID != folderIds.EntryId)
                {
                    if (MoveMessage(storeId, entryId, folderID, folderIds))
                    {
                        return(true);
                    }
                }
            }
            OutlookSession.DeleteMessageImpl(storeId, entryId, false);
            return(true);
        }