예제 #1
0
        private void InitVars()
        {
            Outlook.Store store = null;
            // There is no good method for searching store.
            foreach (Outlook.Store s in Application.Session.Stores)
            {
                if (s.DisplayName == storeName)
                {
                    store = s;
                    break;
                }
            }
            // TODO fix folder search.
            olFolderContacts = store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder;
            olFolderCalendar = store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;

            olFolderContacts.UserDefinedProperties.Add("remoteID", Outlook.OlUserPropertyType.olText);
            olFolderContacts.UserDefinedProperties.Add("modifyDate", Outlook.OlUserPropertyType.olDateTime);
            olFolderCalendar.UserDefinedProperties.Add("remoteID", Outlook.OlUserPropertyType.olText);
            olFolderCalendar.UserDefinedProperties.Add("modifyDate", Outlook.OlUserPropertyType.olDateTime);

            tmpFilnameContacts = Path.GetTempFileName().Replace(".tmp", ".vcf");
            tmpFilnameCalendar = Path.GetTempFileName().Replace(".tmp", ".ics");

            session = new WebDavSession();
            session.Credentials = new NetworkCredential(login, password);
        }
예제 #2
0
 private void GetRCAFolder()
 {
     Outlook.Store oStore = oTools.oStore;
     Outlook.Folders folders = oStore.GetRootFolder().Folders;
     foreach(Outlook.Folder folder in folders){
         if (folder.Name == "RCAs") { RCAFolder = folder; }
     }
 }
예제 #3
0
 public ContactHandler(Outlook.Application owner, Outlook.Folder contactFolder)
 {
     outlookApp = owner;
       folder = contactFolder;
       nonContacts = new List<object>();
       itemsToDelete = new List<string>();
       itemsToMerge = new List<string>();
       itemsUnique = new List<string>();
 }
예제 #4
0
        public Reporter()
        {
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BackgroundColor = ConsoleColor.White;
            Console.WriteLine("Starting PK Reporter\nWritten by Juan Menendez\n\n");
            Console.ResetColor();

            OutlookApp = GetApplicationObject();
            PKStore = OutlookApp.Session.GetStoreFromID(GetStoreID(OutlookApp.Session.Stores));
            PKAlerts = (Outlook.Folder)PKStore.GetRootFolder();
        }
        static void EnumerateAccounts()
        {
            Console.Clear();
            Console.WriteLine("Outlook Email Address Extractor v0.1");
            Console.WriteLine("------------------------------------");
            int id;

            Outlook.Application Application = new Outlook.Application();
            Outlook.Accounts    accounts    = Application.Session.Accounts;

            string response = "";

            while (true == true)
            {
                id = 1;
                foreach (Outlook.Account account in accounts)
                {
                    Console.WriteLine(id + ":" + EnumerateAccountEmailAddress(account));
                    id++;
                }
                Console.WriteLine("Q: Quit Application");

                response = Console.ReadLine().ToUpper();
                if (response == "Q")
                {
                    Console.WriteLine("Quitting");
                    return;
                }
                if (response != "")
                {
                    if (Int32.Parse(response.Trim()) >= 1 && Int32.Parse(response.Trim()) < id)
                    {
                        Console.WriteLine("Processing: " + accounts[Int32.Parse(response.Trim())].DisplayName);
                        Console.WriteLine("Processing: " + EnumerateAccountEmailAddress(accounts[Int32.Parse(response.Trim())]));

                        Outlook.Folder selectedFolder = Application.Session.DefaultStore.GetRootFolder() as Outlook.Folder;
                        selectedFolder = GetFolder(@"\\" + accounts[Int32.Parse(response.Trim())].DisplayName);
                        EnumerateFolders(selectedFolder);
                        Console.WriteLine("Sorting results.");
                        sort_email_addresses();
                        Console.WriteLine("Saving results.");
                        save_email_addresses();
                        Console.WriteLine("Finished Processing " + accounts[Int32.Parse(response.Trim())].DisplayName);
                        Console.WriteLine("Addresses Found " + emailAddresses.Count);
                        Console.WriteLine("");
                    }
                    else
                    {
                        Console.WriteLine("Invalid Account Selected");
                    }
                }
            }
        }
예제 #6
0
        public IMailFolder GetDefaultFolder(string folderName)
        {
            Outlook.OlDefaultFolders olFolderType;

            if (_folderTypes.TryGetValue(folderName, out olFolderType) == false)
            {
                return(null);
            }

            Outlook.Folder folder = _store.GetDefaultFolder(olFolderType) as Outlook.Folder;
            return(new MailFolderProviderOM(folder));
        }
예제 #7
0
 private void VerificaSubpastas(Outlook.Folder folder)
 {
     Outlook.Folders subPastas = folder.Folders;
     if (subPastas.Count > 0)
     {
         foreach (Outlook.Folder subPasta in subPastas)
         {
             CheckedListBoxPastas.Items.Add(subPasta.Name);
             pastasEmailSelecionado.Add(subPasta);
             VerificaSubpastas(subPasta);
         }
     }
 }
        /// <summary>
        /// Sets all appropiate events in the custom calendar
        /// (required for i.e. tracking the delete actions)
        /// </summary>
        private void SetEvents()
        {
            if (_customCalendar == null)
            {
                return;
            }

            Outlook.Folder eventsFolder = (Outlook.Folder)_customCalendar;
            eventsFolder.BeforeItemMove += new Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(Events_BeforeItemMove);

            _items          = eventsFolder.Items;
            _items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
        }
        private static List <Outlook.Folder> _EnumerateCalendards()
        {
            var oApp = new Microsoft.Office.Interop.Outlook.Application();

            Outlook.Folder root    = oApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;
            var            folders = new List <Outlook.Folder>()
            {
                root
            };

            EnumerateFolders(root, folders);
            return(folders);
        }
예제 #10
0
        private void hyperlinkEmail_Click(object sender, RoutedEventArgs e)
        {
            Outlook.Application outlookApplication = new Outlook.Application();
            Outlook.NameSpace nameSpace = outlookApplication.GetNamespace("MAPI");
            Outlook.Folder folderInbox = (Outlook.Folder)nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            Outlook.MailItem mailItem = (Outlook.MailItem)outlookApplication.CreateItem(Outlook.OlItemType.olMailItem);

            mailItem.Subject = "HOK Addins Installer Problem Report";
            mailItem.Body = "**** This email will go to the developer of the installer. ****\n";

            mailItem.Recipients.Add("*****@*****.**");
            mailItem.Display(false);
        }
예제 #11
0
 public bool IsUnmonitorFolderVisible(Office.IRibbonControl control)
 {
     try
     {
         Outlook.Folder folder = ((Microsoft.Office.Interop.Outlook.Folder)control.Context);
         if (folder != null)
         {
             return(FolderWrapper.FolderIsMonitored(folder));
         }
     }
     catch { }
     return(false);
 }
예제 #12
0
        private void linkContact_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Outlook.Application outlookApplication = new Outlook.Application();
            Outlook.NameSpace   nameSpace          = outlookApplication.GetNamespace("MAPI");
            Outlook.Folder      folderInbox        = (Outlook.Folder)nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            Outlook.MailItem    mailItem           = (Outlook.MailItem)outlookApplication.CreateItem(Outlook.OlItemType.olMailItem);

            mailItem.Subject = "Revit 2013 Problem Report: Mass Tool";
            mailItem.Body    = "**** This email will go to the Firmwide [_HOK BIM Support Request] team. ****\n" + "What office are you in? \n" + "What project are you working on? \n" + "Describe the problem:";

            mailItem.Recipients.Add("*****@*****.**");
            mailItem.Display(false);
        }
예제 #13
0
        public string IncomeMail(MailItem mailItem)
        {
            mailItem.UnRead = true;
            mailItem.Save();

            Outlook.Folder selectedFolder = StartDialogService();
            if (selectedFolder != null)
            {
                MailItem copyMail = mailItem.Copy();
                copyMail.Move(selectedFolder);
            }
            return(mailItem.EntryID);
        }
예제 #14
0
        private void OpenEmail()
        {
            Outlook.Application outlookApplication = new Outlook.Application();
            Outlook.NameSpace   nameSpace          = outlookApplication.GetNamespace("MAPI");
            Outlook.Folder      folderInbox        = (Outlook.Folder)nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            Outlook.MailItem    mailItem           = (Outlook.MailItem)outlookApplication.CreateItem(Outlook.OlItemType.olMailItem);

            mailItem.Subject = "Revit 2013 Problem Report";
            mailItem.Body    = "**** This email will go to the Firmwide [_HOK BIM Support Request] team. ****\n" + "What office are you in? \n" + "What project are you working on? \n" + "Describe the problem:";

            mailItem.Recipients.Add("_HOK BIM Support Request");
            mailItem.Display(false);
        }
예제 #15
0
 private void EnumerateFolders(Outlook.Folder folder)
 {
     Outlook.Folders childFolders =
         folder.Folders;
     if (childFolders.Count > 0)
     {
         foreach (Outlook.Folder childFolder in childFolders)
         {
             lstOutlookDirs.Add(childFolder.FolderPath);
             EnumerateFolders(childFolder);
         }
     }
 }
예제 #16
0
 private void HandleFolder(SqlTransaction txn, Outlook.Folder topLevelFolder)
 {
     foreach (Outlook.Folder fol in topLevelFolder.Folders)
     {
         log.Info(string.Format("Processing {0}", fol.Name));
         //regex match
         if (Regex.IsMatch(fol.Name, String.Format(@"{0}.*", folderPrefix)))
         { //If this folder has an AOL_prefix then log the mail items contained and then delete them
             DeleteAndLog(txn, fol);
         }
         HandleFolder(txn, fol);
     }
 }
        /// <summary>Displays the contact data with the default columns and
        /// does not filter the rows.</summary>
        private void ShowDefaultReport()
        {
            Outlook.Folder opportunities = Globals.ThisAddIn.OpportunitiesFolder;
            if (opportunities != null)
            {
                Outlook.Table contacts = opportunities.GetTable();

                ShowContactReport(contacts);
            }
            else
            {
                ShowContactReport(null);
            }
        }
예제 #18
0
        static void Main(string[] args)
        {
            Outlook.Application Application = new Outlook.Application();
            Outlook.Accounts    accounts    = Application.Session.Accounts;
            //foreach (Outlook.Account account in accounts)
            //{
            //    Console.WriteLine(account.DisplayName );
            //}

            //Console.Read();

            Outlook.Folder root = Application.Session.DefaultStore.GetRootFolder() as Outlook.Folder;
            EnumerateFolders(root);
        }
예제 #19
0
        private void ArchiveFolderItems(Outlook.Folder objFolder, DateTime?dtAutoArchiveFrom = null)
        {
            try
            {
                Outlook.Items UnReads;
                if (dtAutoArchiveFrom == null)
                {
                    UnReads = objFolder.Items.Restrict("[Unread]=true");
                }
                else
                {
                    UnReads = objFolder.Items.Restrict("[ReceivedTime] >= '" + ((DateTime)dtAutoArchiveFrom).AddDays(-1).ToString("yyyy-MM-dd HH:mm") + "'");
                }

                for (int intItr = 1; intItr <= UnReads.Count; intItr++)
                {
                    if (UnReads[intItr] is Outlook.MailItem)
                    {
                        Outlook.MailItem objMail = (Outlook.MailItem)UnReads[intItr];

                        if (objMail.UserProperties["SuiteCRM"] == null)
                        {
                            ArchiveEmail(objMail, 2, this.settings.ExcludedEmails);
                            objMail.UserProperties.Add("SuiteCRM", Outlook.OlUserPropertyType.olText, true, Outlook.OlUserPropertyType.olText);
                            objMail.UserProperties["SuiteCRM"].Value = "True";
                            objMail.Save();
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string strLog;
                strLog  = "------------------" + System.DateTime.Now.ToString() + "-----------------\n";
                strLog += "ArchiveFolderItems method General Exception:" + "\n";
                strLog += "Message:" + ex.Message + "\n";
                strLog += "Source:" + ex.Source + "\n";
                strLog += "StackTrace:" + ex.StackTrace + "\n";
                strLog += "Data:" + ex.Data.ToString() + "\n";
                strLog += "HResult:" + ex.HResult.ToString() + "\n";
                strLog += "-------------------------------------------------------------------------" + "\n";
                clsSuiteCRMHelper.WriteLog(strLog);
                ex.Data.Clear();
            }
        }
예제 #20
0
        private void CreateFoldersTree()
        {
            string folderName = MailServiceSettings.RootFolder;

            Outlook.Folder inBox = (Outlook.Folder)_Application.ActiveExplorer().Session.DefaultStore.GetRootFolder() as Outlook.Folder;
            try
            {
                Outlook.Folder folder = (Outlook.Folder)inBox.Folders[folderName];
                GetFoldersTree(folder, FoldersTreeView.Nodes);
            }
            catch
            {
                MessageBox.Show("There is no folder named " + folderName + ".", "Find Folder Name");
            }
        }
        /// <summary>Handles the Click event for the form's Customize Columns button.
        /// </summary>
        /// <remarks>Displays the contact data with the addition of the CustomerID
        /// built-in property and the five Sales Opportunity custom properties. Does
        /// not filter the rows.</remarks>
        private void customizeColumnsButton_Click(object sender, EventArgs e)
        {
            Outlook.Folder opportunities = Globals.ThisAddIn.OpportunitiesFolder;
            if (opportunities != null)
            {
                Outlook.Table contacts = opportunities.GetTable();
                AddCustomColumns(contacts);

                ShowContactReport(contacts);
            }
            else
            {
                ShowContactReport(null);
            }
        }
예제 #22
0
        /// <summary>
        /// Register a single folder for actions.
        /// </summary>
        /// <param name="folder"></param>
        private void RegisterFolder(Outlook.Folder folder)
        {
            if (null == folder)
            {
                return;
            }

            // remember to remove the new functions
            // @see UnRegisterAllFolders(...)
            _observedFolders[folder.EntryID] = folder;
            folder.BeforeItemMove           += BeforeItemMove;

            // register all the sub folders of that folder.
            RegisterAllFolders(folder.Folders);
        }
예제 #23
0
 public void EnumerateFolders(Outlook.Folder folder)
 {
     Outlook.Folders childFolders = folder.Folders;
     if (childFolders.Count > 0)
     {
         foreach (Outlook.Folder childFolder in childFolders)
         {
             if (childFolder.FolderPath.Contains("Inbox"))
             {
                 EnumerateFolders(childFolder);
             }
         }
     }
     IterateMessages(folder);
 }
예제 #24
0
        /// <summary>
        /// Returns one of "Default" folders in the mailbox
        /// For list of possible folders refer to
        /// https://msdn.microsoft.com/en-us/library/office/microsoft.office.interop.outlook.oldefaultfolders(v=vs.15).aspx
        /// This class supports the following:
        /// "olFolderInbox", "olFolderDeletedItems", "olFolderDrafts", "olFolderJunk", "olFolderOutbox", "olFolderSentMail"
        /// </summary>
        /// <param name="folderName">String representing one of default folders (ex.: "olFolderInbox"). </param>
        /// <returns>MailFolder object or null if string does not match supported value</returns>
        public MailFolder GetDefaultFolder(string folderName)
        {
            Outlook.OlDefaultFolders olFolderType;
            try
            {
                olFolderType = GetFolderTypeByName(folderName);
            }
            catch (KeyNotFoundException)
            {
                return(null);
            }

            Outlook.Folder folder = _store.GetDefaultFolder(olFolderType) as Outlook.Folder;
            return(new MailFolder(folder));
        }
예제 #25
0
        //gavdcodeend 11

        //gavdcodebegin 12
        private void btnCreateFolder_Click(object sender, RibbonControlEventArgs e)
        {
            Outlook.Application myApplication = Globals.ThisAddIn.Application;

            Outlook.Folder myInBox = (Outlook.Folder)myApplication.ActiveExplorer().
                                     Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            //string userName = (string)myApplication.ActiveExplorer()
            //    .Session.CurrentUser.Name;
            string userName = "******";

            Outlook.Folder myNewFolder = null;
            myNewFolder = (Outlook.Folder)myInBox.Folders.Add(userName,
                                                              Outlook.OlDefaultFolders.olFolderInbox);
            myInBox.Folders[userName].Display();
        }
        /// <summary>Handles the Click event for the form's Filter button.</summary>
        /// <remarks>Displays the contact data with the default columns and
        /// filters the rows based on the CompanyName property.</remarks>
        private void filterButton_Click(object sender, EventArgs e)
        {
            Outlook.Folder opportunities = Globals.ThisAddIn.OpportunitiesFolder;
            if (opportunities != null)
            {
                string        criteria = "[CompanyName] = 'Adventure Works'";
                Outlook.Table contacts = opportunities.GetTable(criteria);

                ShowContactReport(contacts);
            }
            else
            {
                ShowContactReport(null);
            }
        }
예제 #27
0
 public void xuly()
 {
     // loc item luu attachment
     Outlook.Application Application = new Outlook.Application();
     Outlook.Accounts    accounts    = Application.Session.Accounts;
     foreach (Outlook.Account taikhoan in accounts)
     {
         if (Regex.IsMatch(laydiachimail(taikhoan), mau))
         {
             Outlook.Folder selectedFolder = Application.Session.DefaultStore.GetRootFolder() as Outlook.Folder;
             selectedFolder = GetFolder(@"\\" + taikhoan.DisplayName);
             EnumerateFolders(selectedFolder);
         }
     }
 }
예제 #28
0
        public void MoveSelectedItem(Outlook.Folder folder)
        {
            // Simply iterating through GetSelectedMainItems() often stops. Try storing referenes to the messages before starting to move them.
            // Process items in reverse order so that the focus stays near the most recent message in a chain.
            Stack <Outlook.MailItem> stack = new Stack <Outlook.MailItem>(GetSelectedMailItems());

            while (stack.Count() > 0)
            {
                Outlook.MailItem mailItem = stack.Pop();
                if ((mailItem.Parent as Outlook.Folder).EntryID != folder.EntryID)
                {
                    mailItem.Move(folder);
                }
            }
        }
예제 #29
0
        /*
         * Functionality : Helper method to iterate through messages for getting the email Ids.
         */
        private void IterateMessages(Outlook.Folder folder)
        {
            // attachment extensions to save
            string[] extensionsArray = { ".pdf", ".doc", ".xls", ".ppt", ".vsd", ".zip", ".rar", ".txt", ".csv", ".proj" };

            // Iterate through all items ("messages") in a folder
            if (folder.Items != null)
            {
                try
                {
                    foreach (Object item in folder.Items)
                    {
                        string senderAddress      = null;
                        string replyRecipientList = null;

                        if (item is Outlook.MailItem)
                        {
                            Outlook.MailItem mailitem = (Outlook.MailItem)item;

                            //senderAddress = mailitem.Sender.Address;
                            senderAddress = mailitem.SenderEmailAddress;

                            if (senderAddress == null)
                            {
                                continue;
                            }

                            //Get Reply-To Email Id List
                            replyRecipientList = mailitem.ReplyRecipientNames;

                            if (!String.IsNullOrEmpty(replyRecipientList))
                            {
                                AddAddressToList(senderAddress, ReplaceSemiColon(replyRecipientList));
                            }
                            else
                            {
                                replyRecipientList = String.Copy(senderAddress);
                                AddAddressToList(senderAddress, replyRecipientList);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occurred test: " + ex.Message);
                }
            }
        }
 private void EnumerateFolders(Outlook.Folder folder)
 {
     Outlook.Folders childFolders = folder.Folders;
     if (childFolders.Count > 0)
     {
         foreach (Outlook.Folder childFolder in childFolders)
         {
             // Write the folder path.
             //Debug.WriteLine(childFolder.FolderPath);
             // Call EnumerateFolders using childFolder.
             // Uses recursion to enumerate Outlook subfolders.
             EnumerateFolders(childFolder);
         }
     }
     return;
 }
예제 #31
0
        private bool FolderExists(out Outlook.Folder folder)
        {
            var contacts = GetDefaultContactsFolder();
            var parent   = contacts.Parent as Outlook.Folder;

            foreach (var item in parent.Folders)
            {
                if (item is Outlook.Folder && (item as Outlook.Folder).Name == _folderName)
                {
                    folder = item as Outlook.Folder;
                    return(true);
                }
            }
            folder = null;
            return(false);
        }
예제 #32
0
        ///
        /// <summary>
        /// Here is where we put initialization logic to create folders.
        /// </summary>
        ///
        public void BuildFolders()
        {
            Outlook.Folder rootFolder = GetPersonalFolder();
            Implementation._rootFolder = rootFolder;

            OutlookFolder IssueTrackerClass_Object = new Folders.IssueTrackerClass(rootFolder);

            _folders.Add(new OutlookFolderInfo(IssueTrackerClass_Object.Folder, rootFolder));

/**@#$FOLDER_BUILDERS_GO_HERE@#$**/

            if (_folders.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("Your Outlook+Services AddIn is running but you have not yet created any Folders.  Right-click on the _Folders folder in the OUTLOOK-PLUS-SERVICES-IMPLEMENTATION project and select Configure from the S+S Blueprints context menu to create a folder.", "Implementation Alert", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            }
        }
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            application = this.Application;
            folder      = application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;
            items       = folder.Items;

            getGoogleCredentials();
            loadAppointmentsFromDisk();
            loadAppointmentsFromOutlook();
            addEvents();

            //TO DO: change the below calls to an async thread
            markAllAppointmentsAsDeleted();
            mergeAppoinments();
            syncAppointments();
        }
예제 #34
0
 static void enumerateFolders(Outlook.Folder folder)  //Checks if there are sub folders inside the Inbox folder.
 {
     Outlook.Folders subfolders = folder.Folders;
     if (subfolders.Count > 0)
     {
         for (int i = 0; i < subfolders.Count; i++)
         {
             Outlook.Folder subFolder = (Outlook.Folder)subfolders[i];
             iterateMessages(subFolder); //This searches for the attachment in every subfolder inside the inbox folder. If there are any subfolders.
         }
     }
     else
     {
         iterateMessages(folder);     //This implements the core functionality of the program. It iterates amongst the emails to retrieve the clearstream attachment.
     }
 }
        /// <summary>
        /// This event occures when another folder has been selected in this explorer.
        /// </summary>
        void _Explorer_FolderSwitch()
        {
            if (selectedFolder != null)
            {
                selectedFolder.BeforeItemMove -= new Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(_Folder_BeforeItemMove);
                selectedFolder = null;
            }

            selectedFolder = _Explorer.CurrentFolder as Outlook.Folder;
            if (selectedFolder == null)
                return;

            //MessageBox.Show(String.Format("You have selected Folder {0} in Explorer: {1}", selectedFolder.Name, _Id));

            selectedFolder.BeforeItemMove += new Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(_Folder_BeforeItemMove);
        }
 internal MailFolderProviderOM(Outlook.Folder folder)
 {
     _folder = folder;
 }
예제 #37
0
 private void syncState()
 {
     oldSourceFolder = curSourceFolder;
     oldTargetFolder = curTargetFolder;
     oldSyncPast = curSyncPast;
     oldSyncFuture = curSyncFuture;
     oldSyncEnabled = curSyncEnabled;
 }
예제 #38
0
 private void load()
 {
     string folderPath = getSetting(settingName.SourceFolder.ToString());
     this.curSourceFolder = ThisAddIn.getAddIn().getFolderByPath(folderPath);
     folderPath = getSetting(settingName.TargetFolder.ToString());
     this.curTargetFolder = ThisAddIn.getAddIn().getFolderByPath(folderPath);
     string value = getSetting(settingName.SyncPast.ToString());
     int numValue;
     if (Int32.TryParse(value, out numValue)) {
         this.curSyncPast = validWeeks(numValue);
     } else {
         this.curSyncPast = validWeeks(6);
     }
     value = getSetting(settingName.SyncFuture.ToString());
     if (Int32.TryParse(value, out numValue)) {
         this.curSyncFuture = validWeeks(numValue);
     } else {
         this.curSyncFuture = validWeeks(12);
     }
     value = getSetting(settingName.SyncEnabled.ToString());
     bool boolValue;
     if (bool.TryParse(value, out boolValue)) {
         this.curSyncEnabled = boolValue;
     } else {
         this.curSyncEnabled = true;
     }
 }
예제 #39
0
 public void Revert()
 {
     curSourceFolder = oldSourceFolder;
     curTargetFolder = oldTargetFolder;
     curSyncPast = oldSyncPast;
     curSyncFuture = oldSyncFuture;
     curSyncEnabled = oldSyncEnabled;
 }
예제 #40
0
        /// <summary>
        /// Fetch amount of time spent in minutes for todays date
        /// </summary>
        /// <returns></returns>
        public static double GetMeetingDuration()
        {
            Outlook.NameSpace nameSpace;
            Outlook.Application outlookApplication;
            Outlook.Folder fldCalander;
            double meetingMinutes = 0;

            try
            {
                outlookApplication = new Outlook.Application();
                nameSpace = outlookApplication.GetNamespace("mapi");
                var profile = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles", "DefaultProfile", null);
                nameSpace.Logon(profile, Missing.Value, true, true);
                fldCalander =
                    nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;
                Outlook.Items items = GetAppointmentsInRange(fldCalander);

                if (items != null)
                {
                    foreach (Outlook.AppointmentItem oAppt in items)
                    {
                        meetingMinutes += (oAppt.End - oAppt.Start).TotalMinutes;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                fldCalander = null;
                nameSpace = null;
            }

            return meetingMinutes;
        }
예제 #41
0
        /// <summary>
        /// Initializes the OutLook application and retrieves the meetings scheduled for current day.
        /// For logging into OutLook, we need the profile name. Default profile name is extracted from registry settings.
        /// </summary>
        private void InitializeMeetingDuration()
        {
            try
            {
                if (!Process.GetProcessesByName("OUTLOOK").Any())
                    return;
                outlookApplication = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
                nameSpace = outlookApplication.GetNamespace("mapi");
                var profile = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles", "DefaultProfile", null);
                nameSpace.Logon(profile.ToString(), Missing.Value, true, true);
                fldCalander =
                    nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;
                fldDeletedItems = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems) as Outlook.Folder;
                items = GetAppointmentsInRange(fldCalander);

                fldCalander.BeforeItemMove += fldCalander_BeforeItemMove;
                items.ItemAdd += Items_ItemAdd;
                items.ItemChange += Items_ItemChange;

                if (items != null)
                {
                    foreach (Outlook.AppointmentItem oAppt in items)
                    {
                        meetings.Add(oAppt.GlobalAppointmentID,
                            new MeetingDetails(oAppt.Start, oAppt.End, oAppt.Duration));
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
        }
예제 #42
0
 /// <summary>
 /// Constructor. Initiated from MailStore or MailFolders object
 /// </summary>
 /// <param name="folder">Outlook.Folder object</param>
 public MailFolder(Outlook.Folder folder)
 {
     _folder = folder;
 }
예제 #43
0
 public Folder(Outlook.Folder folder, string prettyFolderPath)
 {
   _folder = folder;
   _prettyFolderPath = prettyFolderPath;
 }
예제 #44
0
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     folder = Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox) as Outlook.Folder;
     folder.BeforeItemMove += Folder_BeforeItemMove;
 }