Example #1
0
        public Dictionary <string, bool> GetMessageStores()
        {
            Dictionary <string, bool> stores = new Dictionary <string, bool>();

            if (session_ == null)
            {
                return(stores);
            }
            IntPtr pTable = IntPtr.Zero;

            session_.GetMsgStoresTable(0, out pTable);
            if (pTable == IntPtr.Zero)
            {
                return(stores);
            }
            object    tableObj = null;
            MAPITable mb       = null;

            try
            {
                tableObj = Marshal.GetObjectForIUnknown(pTable);
                mb       = new MAPITable(tableObj as IMAPITable);
                if (mb != null)
                {
                    if (mb.SetColumns(new PropTags[] { PropTags.PR_DISPLAY_NAME, PropTags.PR_DEFAULT_STORE }))
                    {
                        SRow[] sRows;

                        while (mb.QueryRows(1, out sRows))
                        {
                            if (sRows.Length != 1)
                            {
                                break;
                            }
                            stores[sRows[0].propVals[0].AsString] = sRows[0].propVals[1].AsBool;
                        }
                    }
                    mb.Dispose();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            return(stores);
        }
Example #2
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (session_ != null)
         {
             if (CurrentStore != null)
             {
                 CurrentStore.Dispose();
                 CurrentStore = null;
             }
             if (content_ != null)
             {
                 content_.Dispose();
                 content_ = null;
             }
             Marshal.ReleaseComObject(session_);
             session_ = null;
             MAPINative.MAPIUninitialize();
         }
     }
 }
Example #3
0
        public Dictionary<string, bool> GetMessageStores()
        {
            Dictionary<string, bool> stores = new Dictionary<string, bool>();
            if (session_ == null)
                return stores;
            IntPtr pTable = IntPtr.Zero;
            session_.GetMsgStoresTable(0, out pTable);
            if (pTable == IntPtr.Zero)
                return stores;
            object tableObj = null;
            MAPITable mb = null;
            try
            {
                tableObj = Marshal.GetObjectForIUnknown(pTable);
                mb = new MAPITable(tableObj as IMAPITable);
                if (mb != null)
                {
                    if (mb.SetColumns(new PropTags[] { PropTags.PR_DISPLAY_NAME, PropTags.PR_DEFAULT_STORE }))
                    {
                        SRow[] sRows;

                        while (mb.QueryRows(1, out sRows))
                        {
                            if (sRows.Length != 1)
                                break;
                            stores[sRows[0].propVals[0].AsString] = sRows[0].propVals[1].AsBool;
                        }
                    }
                    mb.Dispose();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            return stores;
        }