Example #1
0
        private IEMessage OpenMessage(ref bool wasChanges)
        {
            if (_createNew && _OMTaskId == null)
            {
                return(null);
            }

            wasChanges = false;
            IEMessage message = null;

            if (!_createNew)
            {
                PairIDs IDs = PairIDs.Get(_task);
                if (IDs == null)
                {
                    if (_task.HasProp(PROP.EntryID))
                    {
                        IEFolder taskFolder = OutlookSession.OpenDefaultTaskFolder();
                        if (taskFolder == null)
                        {
                            return(null);
                        }

                        using ( taskFolder )
                        {
                            IDs = new PairIDs(_task.GetStringProp(PROP.EntryID), taskFolder.GetBinProp(MAPIConst.PR_STORE_ENTRYID));
                        }
                    }
                    if (IDs == null)
                    {
                        return(null);
                    }
                }

                message = OutlookSession.OpenMessage(IDs.EntryId, IDs.StoreId);
            }
            if (message == null)
            {
                IEFolder taskFolder = OutlookSession.OpenDefaultTaskFolder();
                if (taskFolder == null)
                {
                    return(null);
                }
                wasChanges = true;

                using ( taskFolder )
                {
                    message  = taskFolder.CreateMessage("IPM.Task");
                    _created = true;
                }
            }
            return(message);
        }