public static void RemoveFormFromPersonalFormsLibrary(string name)
        {
            bool formFound = false;

            Outlook.Table olTable;
            Outlook.Row   olRow;
            string        searchFilter;

            if (null == m_Application)
            {
                Initialise();
            }
            try
            {
                Outlook.MAPIFolder olFolder = GetCommonViewsFolder();
                if (null != olFolder)
                {
                    searchFilter = "[MessageClass] = \"IPM.Microsoft.FolderDesign.FormsDescription\"";
                    olTable      = olFolder.GetTable(searchFilter, Outlook.OlTableContents.olHiddenItems);
                    olTable.Columns.Add(PR_DISPLAY_NAME);
                    olTable.Columns.Add(SEARCH_FORM_MESSAGECLASS);
                    olTable.Columns.Add(PR_LONG_TERM_ENTRYID_FROM_TABLE);
                    olTable.Restrict(searchFilter);
                    while (!olTable.EndOfTable)
                    {
                        olRow = olTable.GetNextRow();
                        if (name.ToLower() == olRow[PR_DISPLAY_NAME].ToString().ToLower())
                        {
                            formFound = true;
                            byte[] entryId = olRow[PR_LONG_TERM_ENTRYID_FROM_TABLE];
                            string temp    = "";
                            for (int i = 0; i < entryId.Length; i++)
                            {
                                temp += entryId[i].ToString("X2");
                            }
                            object item = m_NameSpace.GetItemFromID(temp, olFolder.StoreID);
                            if (item is Outlook.StorageItem)
                            {
                                Outlook.StorageItem storageItem = item as Outlook.StorageItem;
                                storageItem.Delete();
                                Console.WriteLine("Form succesfully deleted. You might need to restart Outlook.");
                            }
                        }
                    }
                    if (!formFound)
                    {
                        Console.WriteLine("The form couldn't be found in the Personal Forms Library.");
                    }
                }
                ClearLocalFormCache();
            }
            catch (Exception exception)
            {
                Console.WriteLine("Unable to remove form. Error: " + exception.ToString());
            }
            finally
            {
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Read all possible contact and return it
        /// </summary>
        /// <param name="cacheTimeStamp">For future using</param>
        /// <returns>Distionry where key is EntryID and Value is Last Modification Time</returns>
        public Dictionary <string, DateTime> GetTableFilter(DateTime cacheTimeStamp)
        {
            //string criteria = string.Format("[LastModificationTime] > '{0}'", cacheTimeStamp.ToString("yyyyMMdd HH:mm:ss"));
            Outlook.Table table = _ContactFolder.GetTable(Type.Missing, Type.Missing);
            Dictionary <string, DateTime> ret = new Dictionary <string, DateTime>();

            while (!table.EndOfTable)
            {
                Outlook.Row nextRow = table.GetNextRow();
                ret.Add(nextRow["EntryID"].ToString(), (DateTime)nextRow["LastModificationTime"]);
            }
            return(ret);
        }