Example #1
0
 /// <summary>
 /// The NewExplorer event fires whenever a new Explorer is displayed.
 /// </summary>
 /// <param name="Explorer"></param>
 private void m_Explorers_NewExplorer(Outlook.Explorer Explorer)
 {
     try
     {
         // Check to see if this is a new window
         // we don't already track
         OutlookExplorer existingWindow =
             FindOutlookExplorer(Explorer);
         // If the m_Windows collection does not
         // have a window for this Explorer,
         // we should add it to m_Windows
         if (existingWindow == null)
         {
             OutlookExplorer window = new OutlookExplorer(Explorer);
             window.Close             += new EventHandler(WrappedWindow_Close);
             window.InvalidateControl += new EventHandler <
                 OutlookExplorer.InvalidateEventArgs>(
                 WrappedWindow_InvalidateControl);
             m_Windows.Add(window);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
Example #2
0
 Microsoft.Office.Interop.Outlook.MailItem selectedOutlookMessages()
 {
     Microsoft.Office.Interop.Outlook.Application myOlApp = new Microsoft.Office.Interop.Outlook.Application();
     Microsoft.Office.Interop.Outlook.Explorer    objView = myOlApp.ActiveExplorer();
     Microsoft.Office.Interop.Outlook.MailItem    olMail  = (MailItem)objView.Selection;
     return(olMail);
 }
Example #3
0
 public static Outlook.TaskItem GetSelectedTask()
 {
     try
     {
         Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
         if (explorer.Selection.Count == 1)
         {
             Object selItem = explorer.Selection[1];
             if (selItem is Outlook.TaskItem)
             {
                 Outlook.TaskItem task = (Outlook.TaskItem)selItem;
                 return(task);
             }
             else
             {
                 MessageBox.Show("This facility currently only handles tasks items");
                 return(null);
             }
         }
         else
         {
             MessageBox.Show("This facility will not handle bulk selection");
             return(null);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Unable to select e-mail");
         XLtools.LogException("GetSelectedEmail", ex.ToString());
         return(null);
     }
 }
Example #4
0
        private TaskPaneContext(Outlook.Explorer explorer, Outlook.Inspector inspector)
        {
            this.explorer  = explorer;
            this.inspector = inspector;

            var wrapper = new TaskPaneControlWrapper();

            taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(wrapper, "Quick Move", explorerOrInspector);
            taskPane.VisibleChanged += new EventHandler(TaskPane_VisibleChanged);
            control = wrapper.taskPaneControl;
            control.SetUp();
            control.taskPaneContext = this;

            if (this.explorer is null)
            {
                // Init inspector
                ((Outlook.InspectorEvents_Event) this.inspector).Close += new Outlook.InspectorEvents_CloseEventHandler(CloseCallback);
            }
            else
            {
                // Init explorer
                ((Outlook.ExplorerEvents_10_Event) this.explorer).Close           += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_CloseEventHandler(CloseCallback);
                ((Outlook.ExplorerEvents_10_Event) this.explorer).SelectionChange += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_SelectionChangeEventHandler(Explorer_SelectionChange);
            }

            GuessBestFolderAsync();
        }
Example #5
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Get the Application object
            Outlook.Application application = this.Application;
            // Get the Inspector object
            Outlook.Inspectors inspectors = application.Inspectors;
            // Get the active Inspector object
            Outlook.Inspector activeInspector = application.ActiveInspector();
            if (activeInspector != null)
            {
                // Get the title of the active item when the Outlook start.
                MessageBox.Show("Active inspector: " + activeInspector.Caption);
            }

            // ...
            // Add a new Inspector to the application
            inspectors.NewInspector +=
                new Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_AddTextToNewMail);


            // Get the Explorer objects
            Outlook.Explorers explorers = application.Explorers;
            // Get the active Explorer object
            Outlook.Explorer activeExplorer = application.ActiveExplorer();
            if (activeExplorer != null)
            {
                // Get the title of the active folder when the Outlook start.
                MessageBox.Show("Active explorer: " + activeExplorer.Caption);
            }
        }
Example #6
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            //Configure logging
            log4net.Config.XmlConfigurator.Configure();

            try
            {
                log.Info("Add-in startup");

                //Start cleanup timer
                int cleanupTimerInterval = int.Parse(System.Configuration.ConfigurationManager.AppSettings["CleanupTimerInterval"]);
                log.InfoFormat("Starting cleanup timer -- run every {0} minutes", cleanupTimerInterval);
                cleanupTimer = new System.Threading.Timer(CleanupTimer_Callback, null, 0, cleanupTimerInterval * 60 * 1000);

                //Hook active explorer ViewChange event
                log.Info("Hooking explorer ViewSwitch event");
                explorer             = this.Application.ActiveExplorer();
                explorer.ViewSwitch += Explorer_ViewSwitch;

                //Hook drag and drop event
                StartHook();
            }
            catch (Exception ex)
            {
                log.Fatal("Fatal error", ex);
                StopHook();
            }
        }
Example #7
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Get the Inspector object
            inspectors = this.Application.Inspectors;

            // Get the active Inspector object
            activeInspector = this.Application.ActiveInspector();
            if (activeInspector != null)
            {
                // Get the title of the active item when the Outlook start.
                Debug.WriteLine("Active inspector: {0}", activeInspector.Caption);
            }

            // Get the Explorer objects
            explorers = this.Application.Explorers;

            // Get the active Explorer object
            activeExplorer = this.Application.ActiveExplorer();
            if (activeExplorer != null)
            {
                // Get the title of the active folder when the Outlook start.
                Debug.WriteLine("Active explorer: {0}", activeExplorer.Caption);
            }

            config.PropertyChanged += Config_PropertyChanged;
            if (config.AddInEnabled)
            {
                addComposingEventHandler();
            }
        }
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     currentExplorer = this.Application.ActiveExplorer();
     currentExplorer.SelectionChange += new Outlook
                                        .ExplorerEvents_10_SelectionChangeEventHandler
                                            (CurrentExplorer_Event);
 }
Example #9
0
        public void OnCategoriesAction(Office.IRibbonControl control)
        {
            Outlook.Inspector inspector = null;
            if (ControlIsInInspector(control, ref inspector) == true)
            {
                Outlook.MailItem mailItem = inspector.CurrentItem as Outlook.MailItem;
                if (mailItem != null)
                {
                    mailItem.Categories = "";
                    mailItem.Categories = control.Tag;
                    mailItem.Save();
                }
                return;
            }

            Outlook.Explorer explorer = null;
            if (ControlIsInExplorer(control, ref explorer) == true)
            {
                Outlook.Selection selection = explorer.Selection;
                foreach (var selected in selection)
                {
                    Outlook.MailItem mailItem = selected as Outlook.MailItem;
                    if (mailItem != null)
                    {
                        mailItem.Categories = "";
                        mailItem.Categories = control.Tag;
                        mailItem.Save();
                    }
                }
                return;
            }
        }
 /// <summary>Handles the start up event of the add-in.</summary>
 /// <remarks>Subscribes to the folder switch event of the active
 /// explorer.</remarks>
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     explorer = Application.ActiveExplorer();
     explorer.FolderSwitch +=
         new Outlook.ExplorerEvents_10_FolderSwitchEventHandler(
             explorer_FolderSwitch);
 }
Example #11
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Create the AppData and ImageCache folders, if needed
            Directory.CreateDirectory(Common.appFolder);
            Directory.CreateDirectory(Common.imageCacheFolder);

            // Get a List of all files still in the Image Cache
            string[] allFiles = Directory.GetFiles(Common.imageCacheFolder);

            // Clear the Image Cache, if any images exist
            if (allFiles.Length > 0)
            {
                for (int i = allFiles.Length - 1; i >= 0; i--)
                {
                    File.Delete(allFiles[i]);
                }
            }

            // Get the Outlook Namespace so we can monitor incoming messages
            outlookNameSpace = this.Application.GetNamespace("MAPI");
            inbox            = outlookNameSpace.GetDefaultFolder(
                Outlook.OlDefaultFolders.olFolderInbox);

            // Get a list of inbox items and add an event flag for when new items are added (a message is received)
            // EVENT IS CURRENTLY DISABLED, AUTOMATED CONVERSION CAUSING TOO MUCH MEMORY OVERHEAD
            //items = inbox.Items;
            //items.ItemAdd +=
            //    new Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);

            // Set Event to Trigger any time a new window takes focus
            currentExplorer = Application.ActiveExplorer();
            currentExplorer.SelectionChange += new Outlook
                                               .ExplorerEvents_10_SelectionChangeEventHandler
                                                   (ExplorerChanged);
        }
Example #12
0
        public void save_Emails()
        {
            Microsoft.Office.Interop.Outlook.Application myOlApp = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.Explorer    objView = myOlApp.ActiveExplorer();
            filePathPicked = FolderPicker();
            foreach (Microsoft.Office.Interop.Outlook.MailItem olMail in objView.Selection)
            {
                string subj     = olMail.Subject.ToString();
                string FileName = olMail.SentOn.ToString("yyddmm-hhmmss") + "-" +
                                  olMail.SenderEmailAddress.ToString() + "-" +
                                  subj;

                FileName = FileName.Replace("\\", " ");
                FileName = FileName.Replace("/", " ");
                FileName = FileName.Replace(".", " ");
                FileName = FileName.Replace("|", " ");
                FileName = FileName.Replace("*", " ");
                FileName = FileName.Replace("*", " ");
                FileName = FileName.Replace("?", " ");
                FileName = FileName.Replace(":", " ");
                FileName = FileName.Replace("<", " ");
                FileName = FileName.Replace(">", " ");

                string savepath = filePathPicked + "\\" + FileName + ".txt";
                olMail.SaveAs(savepath, 0);
            }
            ;
        }
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            Directory.CreateDirectory(Path.GetDirectoryName(killRscript));
            Directory.CreateDirectory(Path.GetDirectoryName(dataFile));

            // File.WriteAllText(killRscript, " kill the rscript");


            Directory.CreateDirectory(Path.GetDirectoryName(predictScriptPath));
            var files = new List <string>()
            {
                signalFile, killRscript, predictionFile
            };

            foreach (var filePath in files)
            {
                if (File.Exists(filePath))
                {
                    while (IsFileLocked(filePath))
                    {
                        System.Threading.Thread.Sleep(1);
                    }
                    File.Delete(filePath);
                }
            }

            thisExplorer = this.Application.ActiveExplorer();
            thisExplorer.SelectionChange += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_SelectionChangeEventHandler(Access_All_Form_Regions);
            ((Outlook.ApplicationEvents_11_Event)Application).Quit += new Outlook.ApplicationEvents_11_QuitEventHandler(ThisAddIn_Quit);
            Thread th = new Thread(StartPredictionScript);

            th.Start();
        }
        public void fillMails()
        {
            _Mails = new ObservableCollection <MailItem>();
            Microsoft.Office.Interop.Outlook.Application app = Globals.ThisAddIn.Application;
            Microsoft.Office.Interop.Outlook.Explorer    exp = app.ActiveExplorer();

            if (exp.Selection.Count > 0)
            {
                //MessageBox.Show(exp.Selection.Count.ToString());
                for (int i = 1; i <= exp.Selection.Count; i++)
                {
                    Object selObject = exp.Selection[i];
                    if (selObject is MailItem)
                    {
                        MailItem mailItem =
                            (selObject as MailItem);
                        if (mailItem.Subject == null)
                        {
                            mailItem.Subject = "***Kein Betreff***";
                        }
                        _Mails.Add(mailItem);
                    }
                }
            }
        }
Example #15
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Get the Application object
            Outlook.Application application = this.Application;

            // Get the Inspectors objects
            Outlook.Inspectors inspectors = application.Inspectors;

            // Get the active Inspector
            Outlook.Inspector activeInspector = application.ActiveInspector();

            // Get the Explorers objects
            Outlook.Explorers explorers = application.Explorers;

            // Get the active Explorer object
            Outlook.Explorer activeExplorer = application.ActiveExplorer();

            // Add a new Inspector to the application
            inspectors.NewInspector +=
                new Outlook.InspectorsEvents_NewInspectorEventHandler(
                    Inspectors_AddTextToNewMail);

            // Subscribe to the ItemSend event, that it's triggered when an email is sent
            application.ItemSend +=
                new Outlook.ApplicationEvents_11_ItemSendEventHandler(
                    ItemSend_BeforeSend);

            // Add a new Inspector to the application
            inspectors.NewInspector +=
                new Outlook.InspectorsEvents_NewInspectorEventHandler(
                    Inspectors_RegisterEventWordDocument);
        }
Example #16
0
        /* This method is called when the addin first starts
         * Functionality : This method initializes connection, updates the DB for the first time
         * and sets up all the Event Handlers.
         */
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); //Important DO NOT Delete

            //Startup and ItemLoad Event Handlers
            this.Application.Startup  += ApplicationStartup;
            this.Application.ItemLoad += ApplicationItemLoad;
            Instance = this;

            //Check if table is populated
            bool isUpdated = CheckInitialStatus();

            if (!isUpdated)
            {
                GetEmailFromInbox();      //Get EmailId from Inbox
                InsertAddress();          //Insert EmailId in DB
                NoteStatus();             //Update config table
                emailProtection   = true; //If first run, enable email protection
                replytoProtection = true; //If first run, enable reply-to protection
            }
            outlookNameSpace = this.Application.GetNamespace("MAPI");
            inbox            = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
            items            = inbox.Items;
            items.ItemAdd   += new Outlook.ItemsEvents_ItemAddEventHandler(itemsEmailReceived); //Event Handler for new incoming emails

            //Explorer Events Event Handler : Main Trigger
            currentExplorer = this.Application.ActiveExplorer();
            currentExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorerEvent);
        }
Example #17
0
        void Explorer_SelectionChange()
        {
            WriteToLog("Explorer_SelectionChange");

            Outlook.Explorer
                explorer;

            if ((explorer = Application.ActiveExplorer()) == null)
            {
                return;
            }

            #if SHOW_PATH
            if (explorer.CurrentFolder != null)
            {
                WriteToLog(string.Format("Name: {0} FolderPath: {1} FullFolderPath: {2} WebViewOn: {3}", explorer.CurrentFolder.Name, explorer.CurrentFolder.FolderPath, explorer.CurrentFolder.FullFolderPath, explorer.CurrentFolder.WebViewOn));
            }
            #endif

            Outlook.MailItem
                mailItem;

            if (explorer.Selection == null ||
                explorer.Selection.Count == 0 ||
                (mailItem = explorer.Selection[1] as Outlook.MailItem) == null ||
                mailItem.MessageClass == CustomMessageClass
                /*|| GetMailItemHeaderFrom(mailItem)==string.Empty*/)
            {
                return;
            }

            ChangeMessageClass(mailItem);
        }
        private Outlook.Explorer m_WindowsNew; // wrapped window object

        #endregion Fields

        #region Constructors

        /// <summary>
        /// <c>OutlookExplorerWrapper</c>
        /// Create new instance for explorer class 
        /// </summary>
        /// <param name="explorer"></param>
        public OutlookExplorerWrapper(Outlook.Explorer explorer)
        {
            //m_WindowsNew = explorer;
            m_WindowsNew = ThisAddIn.OutlookObj.ActiveExplorer();
            cbWidget = m_WindowsNew.CommandBars;
            ((Outlook.ExplorerEvents_Event)explorer).Close += new Microsoft.Office.Interop.Outlook.ExplorerEvents_CloseEventHandler(OutlookExplorerNew_Close);
        }
Example #19
0
        /// <summary>
        /// Add SyncBar if it is not there.
        /// When creating a command bar or a button, Outlook just has the meta data of the GUI updated. So even after the assembly of the addin
        /// is removed, the command bar along with the buttons are still there.
        /// http://www.add-in-express.com/docs/net-commandbar-tips.php#visibility-rules
        /// </summary>
        void AddSyncBar()
        {
            Outlook.Explorer explorer = Application.ActiveExplorer();

            IEnumerable <Office.CommandBar> bars = explorer.CommandBars.OfType <Office.CommandBar>().Where(item =>
                                                                                                           item.Name == syncBarName);

            syncBar = bars.FirstOrDefault();
            if (syncBar == null)
            {
                syncBar = explorer.CommandBars.Add(syncBarName, Office.MsoBarPosition.msoBarTop, false, false);
            }

#if DEBUG
            ClearButtons();
#endif
            syncButton        = GetButton("Fonlow.SyncML.Sync", "Sync", "Display the sync center", OutlookSyncMLAddIn.Properties.Resources.sync16);
            syncButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(syncButton_Click);

            optionsButton        = GetButton("Fonlow.SyncML.Options", "Options", "Display the Options of sync", OutlookSyncMLAddIn.Properties.Resources.Settings16);
            optionsButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(optionsButton_Click);

            syncBar.Visible = true;

#if DEBUG
            logButton        = GetButton("Fonlow.SyncML.Log", "Log", "Log window", null);
            logButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(logButton_Click);
#endif
        }
Example #20
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            currentExplorer = this.Application.ActiveExplorer();
            currentExplorer.SelectionChange += new Outlook
                                               .ExplorerEvents_10_SelectionChangeEventHandler
                                                   (CurrentExplorer_Event);

            try
            {
                //create path
                if (!Directory.Exists(path))
                {
                    var di = Directory.CreateDirectory(path);
                    di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
                }


                writeConfigFile();

                loadFolderNames();
            }
            catch (Exception exeption)
            {
                MessageBox.Show("Hiba az adatok olvasása során, kérem ellenőrizze a megadott mappákat.", "Sikertelen adat olvasás.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            //local check
            LocalToNetwork();
        }
Example #21
0
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     _currentExplorer = Application.ActiveExplorer();
     _currentExplorer.SelectionChange += CurrentExplorer_Event;
     ((Outlook.ApplicationEvents_11_Event)Application).Quit += ThisAddIn_Quit;
     MainController.OnAddinStartup(_currentExplorer.Session.SyncObjects[1]);
 }
        public void InstantSearch()
        {
            // Get outlook window
            var desktop   = AutomationElement.RootElement;
            var nameSpace = outlookApp.GetNamespace("MAPI");

            Outlook.MAPIFolder folder        = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            string             userName      = folder.Parent.Name;
            var condition_Outlook            = new PropertyCondition(AutomationElement.NameProperty, "Inbox - " + userName + " - Outlook");
            AutomationElement window_outlook = Utilities.WaitForElement(desktop, condition_Outlook, TreeScope.Children, 10);

            // Create the recall function for when "Microsoft Outlook" window opening
            AutomationEventHandler eventHandler = new AutomationEventHandler(Utilities.OnWindowOpen);

            // Registers the listener event
            Automation.AddAutomationEventHandler(WindowPattern.WindowOpenedEvent, window_outlook, TreeScope.Children, eventHandler);

            Outlook.Explorer explorer = outlookApp.Explorers.Add(inboxFolders as Outlook.Folder, Outlook.OlFolderDisplayMode.olFolderDisplayNormal);
            string           filter   = "subject:" + "\"" + "subject" + "\"" + " received:(last month)";

            explorer.Search(filter, Outlook.OlSearchScope.olSearchScopeAllFolders);
            explorer.Display();

            // Parse the saved trace using MAPI Inspector
            List <string> allRopLists = new List <string>();
            bool          result      = MessageParser.ParseMessage(out allRopLists);

            // Update the XML file for the covered message
            Utilities.UpdateXMLFile(allRopLists);

            // Assert failed if the parsed result has error
            Assert.IsTrue(result, "Case failed, check the details information in error.txt file.");
        }
Example #23
0
        private void ExplorerSelectionChange()
        {
            _activeExplorer = Application.ActiveExplorer();
            if (_activeExplorer == null)
            {
                return;
            }
            Outlook.Selection selection = _activeExplorer.Selection;

            if (_ribbon != null)
            {
                if (selection != null && selection.Count == 1 && selection[1] is Outlook.MailItem)
                {
                    // one Mail object is selected
                    Outlook.MailItem selectedMail = selection[1] as Outlook.MailItem; // (collection is 1-indexed)
                                                                                      // tell the ribbon what our currently selected email is by setting this custom property, and run code against it
                    _ribbon.CurrentEmail = selectedMail;
                }
                else
                {
                    _ribbon.CurrentEmail = null;
                }

                _ribbon.SetRibbonButtonStatus(_ribbon.CurrentEmail != null);
            }
        }
Example #24
0
        public void Button_Click(Office.IRibbonControl control)
        {
            try
            {
                Outlook.Recipient  recipient  = null;
                Outlook.Recipients recipients = null;

                Outlook.Application application = new Outlook.Application();
                Outlook.Explorer    explorer    = application.ActiveExplorer();
                Outlook.Inspector   inspector   = application.ActiveInspector();
                inspector.Activate();
                Outlook._MailItem mailItem = inspector.CurrentItem;

                //Outlook.Application outlookApplication = new Outlook.Application();
                //Outlook.MailItem mail = (Outlook.MailItem)outlookApplication.ActiveInspector().CurrentItem;

                if (mailItem != null)
                {
                    recipients = mailItem.Recipients;
                    recipients.ResolveAll();
                    String       StrR            = "";
                    const string PR_SMTP_ADDRESS =
                        "http://schemas.microsoft.com/mapi/proptag/0x39FE001E";
                    foreach (Outlook.Recipient recip in recipients)
                    {
                        Outlook.PropertyAccessor pa = recip.PropertyAccessor;
                        string smtpAddress          =
                            pa.GetProperty(PR_SMTP_ADDRESS).ToString();

                        string[] strsplit = smtpAddress.Split('@');
                        if (!StrR.Contains(strsplit[1]))
                        {
                            StrR += strsplit[1] + Environment.NewLine;
                        }
                    }
                    if (StrR != string.Empty)
                    {
                        MyMessageBox ObjMyMessageBox = new MyMessageBox();
                        ObjMyMessageBox.ShowBox(StrR);
                    }



                    //recipient.Resolve();
                    //                DialogResult result = MessageBox.Show("Are you sure you want to send emails to the following domains " + StrR, "Varify Domains ",
                    //MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    //                if (result == DialogResult.Yes)
                    //                {
                    //                    //code for Yes
                    //                }
                    //                else
                    //                {

                    //                }
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #25
0
 // Only show MyTab when Explorer Selection is
 // a received mail or when Inspector is a read note
 public bool MyTab_GetVisible(Office.IRibbonControl control)
 {
     if (control.Context is Outlook.Explorer)
     {
         Outlook.Explorer explorer =
             control.Context as Outlook.Explorer;
         Outlook.Selection selection = explorer.Selection;
         if (selection.Count == 1)
         {
             if (selection[1] is Outlook.MailItem)
             {
                 Outlook.MailItem oMail =
                     selection[1] as Outlook.MailItem;
                 if (oMail.Sent == true)
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     else if (control.Context is Outlook.Inspector)
     {
         Outlook.Inspector oInsp =
             control.Context as Outlook.Inspector;
         if (oInsp.CurrentItem is Outlook.MailItem)
         {
             Outlook.MailItem oMail =
                 oInsp.CurrentItem as Outlook.MailItem;
             if (oMail.Sent == true)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(true);
     }
 }
        private void ThisAddIn_Startup(object sender, EventArgs e)
        {
            _explorers = Application.Explorers;
            _explorers.NewExplorer += new Outlook.ExplorersEvents_NewExplorerEventHandler(NewExplorerEventHandler);

            _activeExplorer = Application.ActiveExplorer();
            _activeExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(ExplorerSelectionChange);
        }
Example #27
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            Thread th = new Thread(startPredictionScript);

            th.Start();
            thisExplorer = this.Application.ActiveExplorer();
            thisExplorer.SelectionChange += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_SelectionChangeEventHandler(Access_All_Form_Regions);
        }
        public void Dispose()
        {
            UnBindEvents();
#if (COMRELEASE)
            System.Runtime.InteropServices.Marshal.ReleaseComObject(explorer);
#endif
            explorer = null;
        }
 /// <summary>Handles the shut down event of the add-in.</summary>
 /// <remarks>Unsubscribes from the folder switch event.</remarks>
 private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
 {
     explorer.FolderSwitch +=
         new Outlook.ExplorerEvents_10_FolderSwitchEventHandler(
             explorer_FolderSwitch);
     explorer = null;
     ribbonUI = null;
 }
        private void explorers_NewExplorer(RlOutlook.Explorer Explorer)
        {
#if (COMRELEASE)
            System.Runtime.InteropServices.Marshal.ReleaseComObject(Explorer);
#endif
            OutlookExplorer explorer = new OutlookExplorer(explorers[explorers.Count]);
            OnExplorerOpen(explorer);
        }
Example #31
0
        private void ThisAddIn_Startup(object sender, EventArgs e)
        {
            _explorers              = Application.Explorers;
            _explorers.NewExplorer += new Outlook.ExplorersEvents_NewExplorerEventHandler(NewExplorerEventHandler);

            _activeExplorer = Application.ActiveExplorer();
            _activeExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(ExplorerSelectionChange);
        }
Example #32
0
        /// <summary>
        /// <c>CreateFolder</c> member function
        /// create folder  with provided  folder name and its properties
        /// </summary>
        /// <param name="foldername"></param>
        /// <param name="xMLLogProperties"></param>
        public void CreateFolder(string foldername, XMLLogProperties xMLLogProperties)
        {
            try
            {
                string path = UserLogManagerUtility.GetFolderOutLookLocation(foldername);

                path = path.Remove(0, 2);
                string[] folderpath = path.Split('\\');

                Microsoft.Office.Interop.Outlook.Application outlookObj = Globals.ThisAddIn.Application;
                addinExplorer = outlookObj.ActiveExplorer();

                Microsoft.Office.Interop.Outlook.NameSpace outlookNameSpace = outlookObj.GetNamespace("MAPI");
                Microsoft.Office.Interop.Outlook.MAPIFolder oInBox = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
                Microsoft.Office.Interop.Outlook.MAPIFolder parentFolder = (Microsoft.Office.Interop.Outlook.MAPIFolder)oInBox.Parent;
                foreach (Outlook.Folder item in addinExplorer.Session.Folders)
                {
                    if (item.Name.Trim() == folderpath[0])
                    {
                        parentFolder = item;
                    }
                }
                //Gte MAPI Name space

                for (int i = 1; i < folderpath.Length; i++)
                {

                    Microsoft.Office.Interop.Outlook.MAPIFolder f = MAPIFolderWrapper.GetChildFolder(parentFolder, folderpath[i]);
                    if (f != null)
                    {

                        parentFolder = f;
                    }
                    else
                    {

                        if (i < folderpath.Length - 1)
                        {
                            Outlook.MAPIFolder newfolder;
                            newfolder = parentFolder.Folders.Add(folderpath[i], Type.Missing);
                            parentFolder = newfolder;
                        }
                        else
                        {
                            ThisAddIn tad = new ThisAddIn();

                            tad.ReConnection(xMLLogProperties, parentFolder);
                        }
                    }

                }

            }
            catch (Exception ex)
            {

            }
        }
Example #33
0
        void WrapExplorer(Outlook.Explorer explorer)
        {
            ExplorerWrapper wrapper = new ExplorerWrapper(explorer);

            if (wrapper != null)
            {
                wrapper.Closed += explorerWrapper_Closed;
            }
        }
Example #34
0
        private Outlook.Explorer m_Window; // wrapped window object

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Create a new instance of the tracking class for a particular explorer 
        /// </summary>
        /// <param name="explorer">A new explorer window to track</param>
        ///<remarks></remarks>
        public OutlookExplorer(Outlook.Explorer explorer)
        {
            m_Window = explorer;

              // Hookup Close event
              ((Outlook.ExplorerEvents_Event)explorer).Close += new Outlook.ExplorerEvents_CloseEventHandler(OutlookExplorerWindow_Close);

              // Hookup BeforeFolderSwitch event
              m_Window.BeforeFolderSwitch += new Outlook.ExplorerEvents_10_BeforeFolderSwitchEventHandler(m_Window_BeforeFolderSwitch);
        }
        public void NewExplorerEventHandler(Outlook.Explorer explorer)
        {
            if (explorer != null)
            {
                _activeExplorer = explorer;

                //set up event handler so our add-in can respond when a new item is selected in the Outlook explorer window
                _activeExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(ExplorerSelectionChange);
            }
        }
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            explorer = this.Application.ActiveExplorer();

            TaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(new MainContainer(), "Rss Feeds", explorer);
            TaskPane.Visible = false;
            TaskPane.Width = 245;

            //You can set the docking position of the Panel
            TaskPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;

            //You can also restrict the docking position change.
            TaskPane.DockPositionRestrict = Microsoft.Office.Core.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNone;
        }
Example #37
0
        private Outlook.Explorer m_Window; // wrapped window object

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Create a new instance of the tracking class for a particular explorer 
        /// </summary>
        /// <param name="explorer">A new explorer window to track</param>
        ///<remarks></remarks>
        public OutlookExplorer(Outlook.Explorer explorer)
        {
            m_Window = explorer;

            // Hookup Close event
            ((Outlook.ExplorerEvents_Event)explorer).Close +=
                new Outlook.ExplorerEvents_CloseEventHandler(
                OutlookExplorerWindow_Close);

            // Hookup SelectionChange event
            m_Window.SelectionChange +=
                new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(
                    m_Window_SelectionChange);
        }
        /// <summary>
        /// The construction code.
        /// </summary>
        /// <param name="explorer">The outlook explorer that should be wrapped.</param>
        public ExplorerWrapper(Outlook.Explorer explorer)
        {
            _Id = Guid.NewGuid();
            _Explorer = explorer as Outlook.Explorer;
            if (_Explorer == null)
                return;

            Outlook.ExplorerEvents_10_Event explorerEvents = _Explorer as Outlook.ExplorerEvents_10_Event;
            if (explorerEvents == null)
                return;

            explorerEvents.FolderSwitch += new Outlook.ExplorerEvents_10_FolderSwitchEventHandler(_Explorer_FolderSwitch);
            explorerEvents.Close += new Outlook.ExplorerEvents_10_CloseEventHandler(_Explorer_ExplorerEvents_Event_Close);
        }
Example #39
0
        /// <summary>
        ///  assigns properties to member fields
        /// </summary>
        /// <param name="outlookFolder"></param>
        /// <param name="outlookExplorer"></param>
        /// <param name="isFolderMappedWithDocLibrary"></param>
        public UploadBrokenUploads(Outlook.MAPIFolder outlookFolder, Outlook.Explorer outlookExplorer, bool isFolderMappedWithDocLibrary)
        {
            try
            {
                FolderName = outlookFolder.Name;
                //Get the details of the folder. Is it is mapped to SP DocLib or SPSIte(Pages)
                isUserDroppedItemsCanUpload = isFolderMappedWithDocLibrary;
                addinExplorer = outlookExplorer;
                activeDroppingFolder = outlookFolder;
                activeDroppingFolderItems = outlookFolder.Items;

            }
            catch (Exception ex)
            { }
        }
Example #40
0
        /// <summary>
        /// Event Handler for Close event.
        /// </summary>
        private void OutlookExplorerWindow_Close()
        {
            // Unhook explorer-level events

            m_Window.SelectionChange -=
                new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(
                m_Window_SelectionChange);

            ((Outlook.ExplorerEvents_Event)m_Window).Close -=
                new Outlook.ExplorerEvents_CloseEventHandler(
                OutlookExplorerWindow_Close);

            // Raise the OutlookExplorer close event
            if (Close != null)
            {
                Close(this, EventArgs.Empty);
            }

            m_Window = null;
        }
Example #41
0
        /// <summary>
        /// <c>MAPIFolderWrapper</c> member function
        /// assigns properties to member fields and register add event on <c> Outlook.Items</c>
        /// </summary>
        /// <param name="outlookFolder"></param>
        /// <param name="outlookExplorer"></param>
        /// <param name="isFolderMappedWithDocLibrary"></param>
        public MAPIFolderWrapper(ref  Outlook.MAPIFolder outlookFolder, Outlook.Explorer outlookExplorer, bool isFolderMappedWithDocLibrary)
        {
            try
            {
                FolderName = outlookFolder.Name;
                //Get the details of the folder. Is it is mapped to SP DocLib or SPSIte(Pages)
                isUserDroppedItemsCanUpload = isFolderMappedWithDocLibrary;
                addinExplorer = outlookExplorer;
                activeDroppingFolder = outlookFolder;

                activeDroppingFolderItems = outlookFolder.Items;
                activeDroppingFolderItems.ItemAdd -= new Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(activeDroppingFolderItems_ItemAdd);

                //bw.DoWork += delegate(object sender, DoWorkEventArgs e) { bw_DoWork(sender, e, Item); };

            }
            catch (Exception ex)
            { }

            activeDroppingFolderItems.ItemAdd += new Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(activeDroppingFolderItems_ItemAdd);
        }
        private void ExplorerSelectionChange()
        {
            _activeExplorer = Application.ActiveExplorer();
            if (_activeExplorer == null) { return; }
            Outlook.Selection selection = _activeExplorer.Selection;

            if (_ribbon != null)
            {
                if (selection != null && selection.Count == 1 && selection[1] is Outlook.MailItem)
                {
                    // one Mail object is selected
                    Outlook.MailItem selectedMail = selection[1] as Outlook.MailItem; // (collection is 1-indexed)
                                                                                      // tell the ribbon what our currently selected email is by setting this custom property, and run code against it
                    _ribbon.CurrentEmail = selectedMail;
                }
                else
                {
                    _ribbon.CurrentEmail = null;
                }

                _ribbon.SetRibbonButtonStatus(_ribbon.CurrentEmail != null);
            }
        }
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // VSTO Runtime Update to Address Slow Shutdown and “Unknown Publisher” for SHA256 Certificate
            // http://softwareblog.morlok.net/2014/12/03/unknown-publisher-when-installing-clickonce-vsto-outlook-plugin-signed-with-sha256-certificate/
            // http://blogs.msdn.com/b/vsto/archive/2014/04/10/vsto-runtime-update-to-address-slow-shutdown-and-unknown-publisher-for-sha256-certificates.aspx
            // http://stackoverflow.com/questions/11540520/how-to-get-installshield-le-to-uninstall-the-existing-installation-automatically
            // http://stackoverflow.com/questions/6447404/configuring-installshield-le-to-remove-previous-versions-built-using-visual-stud

            outlookApp = Application;

            _inspectors = Application.Inspectors;
            _inspectors.NewInspector += _inspectors_NewInspector;

            explorer = Application.ActiveExplorer();
            explorer.SelectionChange += explorer_SelectionChange;
        }
Example #44
0
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     //Outlook.Inspector inspector = new Outlook.Inspector();
     currentExplorer = this.Application.ActiveExplorer();
     OutlookAddIn1.rubanAddConge newRuban = new rubanAddConge();
     //Outlook.Folder deletedFolder = (Outlook.Folder)this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems);
     //this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems)
     //deletedFolder.Items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(DeletedItems_ItemAdd);
 }
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Custom context menu item event managed
            this.Application.ItemContextMenuDisplay += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(MenuItem_ItemContextMenuDisplay);

            slxUserControl = new CustomTaskPane.SLX_UserControl();
            slxTaskPane = this.CustomTaskPanes.Add(slxUserControl, "SalesLogix");
            slxTaskPane.Visible = true;
            slxTaskPane.Width = 290;

            activeExplorer = this.Application.ActiveExplorer();

            activeExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(activeExplorer_SelectionChange);

            selectExplorers = this.Application.Explorers;

            selectExplorers.NewExplorer += new Outlook
                .ExplorersEvents_NewExplorerEventHandler(newExplorer_Event);

            AddToolbar();
        }
        private void SaveToGoogleDriveAddIn_Startup(object sender, System.EventArgs e)
        {
            CurrentExplorer = this.Application.ActiveExplorer();

            CurrentExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event);
        }
Example #47
0
        /// <summary>
        /// Event Handler for Close event.
        /// </summary>
        private void OutlookExplorerWindow_Close()
        {
            // Unhook explorer-level events
              m_Window.BeforeFolderSwitch -= new Outlook.ExplorerEvents_10_BeforeFolderSwitchEventHandler(m_Window_BeforeFolderSwitch);

              ((Outlook.ExplorerEvents_Event)m_Window).Close -= new Outlook.ExplorerEvents_CloseEventHandler(OutlookExplorerWindow_Close);

              // Raise the OutlookExplorer close event
              if (Close != null)
              {
            Close(this, EventArgs.Empty);
              }

              m_Window = null;
        }
Example #48
0
        /// <summary>
        ///<c>ThisAddIn_Startup</c>  Outlook startup event
        /// This Event is  executed when outlook starts(outlook is opened)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            try
            {

                //declare and initialize variables used for the Instant PLUS check
                Int32 result = 0;

                string filePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\ITOPIA\\SharePoint Link 2010\\", "SharePoint Link.xml");

                //Make the call to Instant PLUS and store the result
                result = Ip2LibManaged.CallInstantPLUS(Ip2LibManaged.FLAGS_NONE, "30820274020100300D06092A864886F70D01010105000482025E3082025A02010002818100BA81817A32C249909671428137ECFC2AEF45E5F746C218550C2191F525A15E65DCD87CAD8B46EB870E55897D1D185B9D88BCDDB6D44CB8B9DDFD7DB4948E8CF91743377F31DB733438828CA0EC3176D8650C8F4B77578E60285F55049D9A707C61FF75C7C626492415BBCBE8058E4F220826A356F1C50B29C92B354C61BEF21F0201110281800AF88F254E47A9F97242E5CB5DA4874DD1D6EF68E60B6AD7D389810E6BA0149C94853482ADD6FECBB58C8F9DF2A71472ADB0C1BF75E665381C1DF855EA9EF93BBA5432731B506EDFE944C217EB09F27AA8203C7D7310D78995A9549690836B313CDCD0B2FA6AD79576977EB44B33D46577E9EA6939DCF8388761E25C3FADF9B1024100F3F70346EEA01874427576DFF5136A9B3A1AB4522ADD2073669376540C6CE65A1A613D0F4754FAD4C8DA70D3F5F5F0D4DAF97B0CF49D9BDA0ECE0F8F46A19BBF024100C3B4DA9372E3FDE1787C322A5B74F21800CDD6A4A85C1DC9D18D40B0F8736BDD3CF45CD5DDB8FD626CD1F11B1127439036A4974D257AF38EBCDD1D9CE08FC1A1024100AC35E43211DA6B9D5C16AE43BC0DB4A9CEA9703A00239E6F93B36295AE6AFCF44EDB3A28E70ECF2CCA039AEFF8E9D72CD6CE38BDD9D8AA3F91FADDCE8C35D75902405095C369E40386A8228D7E1170F3EB370F63D0DA63713971382B1AA3392077B57373ADC1796A4A3796385438525B762C52BC3E4CF150BEA42FA6577CD4EFE65102405162E2024CE04279E92731B490BE2431758FA6D032B0DB85B2AC782956832095800B4A8AB7D6FC1DB905CA38508FC3CC49994A48940CF9BB5761C07A9289D492", filePath);

                if (11574 != result)
                {
                    //this.Close();
                    //this.Application.ActiveExplorer().Close();
                    //this.Application.Quit();
                    return;
                }

                isAuthorized = true;

                #region Add-in Express Regions generated code - do not modify
                this.FormsManager = AddinExpress.OL.ADXOlFormsManager.CurrentInstance;
                this.FormsManager.OnInitialize +=
                    new AddinExpress.OL.ADXOlFormsManager.OnComponentInitialize_EventHandler(this.FormsManager_OnInitialize);
                //this.FormsManager.ADXBeforeFolderSwitchEx +=
                //     new AddinExpress.OL.ADXOlFormsManager.BeforeFolderSwitchEx_EventHandler(FormsManager_ADXBeforeFolderSwitchEx);

                this.FormsManager.Initialize(this);
                #endregion

                //DateTime dtExpiredDate = new DateTime(2010, 08, 05);
                //DateTime dtWorkingDate = DateTime.Now;
                //TimeSpan t = new TimeSpan();
                //t = dtExpiredDate.Subtract(dtWorkingDate);

                //if (t.Days < 30 && t.Days >= 0)
                //{

                //outlookObj = new Outlook.Application();

                OutlookObj = Globals.ThisAddIn.Application;
                //Gte MAPI Name space
                outlookNameSpace = OutlookObj.GetNamespace("MAPI");

                //Get inbox folder
                Outlook.MAPIFolder oInBox = outlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
                //Get current user details to save the xml file based on user
                string userName = outlookNameSpace.DefaultStore.DisplayName;
                userName = userName.Replace("-", "_");
                userName = userName.Replace(" ", "");
                UserLogManagerUtility.UserXMLFileName = userName;

                //Get parent root folder
                Outlook.MAPIFolder olMailRootFolder = (Outlook.MAPIFolder)oInBox.Parent;
                //Get all folder
                oMailRootFolders = olMailRootFolder.Folders;
                //Create folder remove event
                oMailRootFolders.FolderRemove += new Microsoft.Office.Interop.Outlook.FoldersEvents_FolderRemoveEventHandler(oMailRootFolders_FolderRemove);

                //Set inbox folder as default

                try
                {

                    OutlookObj.ActiveExplorer().CurrentFolder = oInBox;
                    addinExplorer = this.Application.ActiveExplorer();
                    addinExplorer.BeforeItemPaste += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_BeforeItemPasteEventHandler(addinExplorer_BeforeItemPaste);
                    //Create folder Switch event
                    addinExplorer.FolderSwitch += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_FolderSwitchEventHandler(addinExplorer_FolderSwitch);

                    //crete folder context menu disply
                    this.Application.FolderContextMenuDisplay += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHandler(Application_FolderContextMenuDisplay);

                    this.Application.ContextMenuClose += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ContextMenuCloseEventHandler(Application_ContextMenuClose);

                    strParentMenuTag = strParentMenuName;
                    // Removing the Existing Menu Bar
                    //  RemoveItopiaMenuBarIfExists(strParentMenuTag);
                    // Adding The Menu Bar Freshly
                    //  CreateParentMenu(strParentMenuTag, strParentMenuName);
                    myTargetFolder = oInBox;
                    CreateAddEventOnFolders();
                    //CreateDefaultAddEventOnFolders();
                    //Create outlook explorer wrapper class
                    OutlookWindow = new OutlookExplorerWrapper(OutlookObj.ActiveExplorer());
                    OutlookWindow.Close += new EventHandler(OutlookWindow_Close);

                    ((Outlook.ExplorerEvents_Event)addinExplorer).BeforeFolderSwitch += new Microsoft.Office.Interop.Outlook.ExplorerEvents_BeforeFolderSwitchEventHandler(ThisAddIn_BeforeFolderSwitch);

                    oMailRootFolders.FolderChange += new Outlook.FoldersEvents_FolderChangeEventHandler(oMailRootFolders_FolderChange);

                    foreach (Outlook.MAPIFolder item in oMailRootFolders)
                    {

                        try
                        {
                            item.Folders.FolderChange -= new Outlook.FoldersEvents_FolderChangeEventHandler(oMailRootFolders_FolderChange);

                        }
                        catch (Exception)
                        {
                        }
                        item.Folders.FolderChange += new Outlook.FoldersEvents_FolderChangeEventHandler(oMailRootFolders_FolderChange);

                    }

                    Outlook.Items activeDroppingFolderItems;

                    activeDroppingFolderItems = oInBox.Items;

                    userOptions = UserLogManagerUtility.GetUserConfigurationOptions();
                    currentFolderSelected = oInBox.Name;
                    currentFolderSelectedGuid = oInBox.EntryID;
                }
                catch (Exception ex)
                {
                    ListWebClass.Log(ex.Message, true);
                }

                // }

            }
            catch (Exception ex)
            {
                EncodingAndDecoding.ShowMessageBox("StartUP", ex.Message, MessageBoxIcon.Error);
            }

            /// <summary>
            //code written by Joy
            ///initializes the object of timer
            /// </summary>

            System.Threading.AutoResetEvent reset = new System.Threading.AutoResetEvent(true);

            timer = new System.Threading.Timer(new System.Threading.TimerCallback(doBackgroundUploading), reset, 180000, 180000);

            GC.KeepAlive(timer);
            form = new Form();
            form.Opacity = 0.01;
            form.Show();
            form.Visible = false;
        }
Example #49
0
        /// <summary>
        /// code written by Joy
        /// excutes ansd the start the timer upload process when the backgoundworkers's do work event fires
        /// </summary>
        /// <param name="Item"></param>
        void doBackGroundUpload(object Item)
        {
            try
              {

              Globals.ThisAddIn.isTimerUploadRunning = true;
              OutlookObj = Globals.ThisAddIn.Application;
              outlookNameSpace = OutlookObj.GetNamespace("MAPI");
              Outlook.MAPIFolder oInBox = outlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
              Outlook.MAPIFolder olMailRootFolder = (Outlook.MAPIFolder)oInBox.Parent;
              oMailRootFolders = olMailRootFolder.Folders;
              Outlook.MailItem moveMail = (Outlook.MailItem)Item;
              string newCatName = "Successfully Uploaded";
              if (Globals.ThisAddIn.Application.Session.Categories[newCatName] == null)
              {
                  outlookNameSpace.Categories.Add(newCatName, Outlook.OlCategoryColor.olCategoryColorDarkGreen, Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone);
              }

              XmlNode uploadFolderNode = UserLogManagerUtility.GetSPSiteURLDetails("", folderName);

              if (uploadFolderNode != null)
              {
                  bool isDroppedItemUplaoded = false;

                  addinExplorer = ThisAddIn.OutlookObj.ActiveExplorer();

                  //Check the folder mapping with documnet library

                  if (isUserDroppedItemsCanUpload == false)
                  {
                      //Show message
                      try
                      {

                          Outlook.MailItem m = (Outlook.MailItem)Item;
                          mailitemEntryID = m.EntryID;

                          try
                          {
                              mailitem = m;

                              mailitemEntryID = m.EntryID;

                              string strsubject = m.EntryID;
                              if (string.IsNullOrEmpty(strsubject))
                              {
                                  strsubject = "tempomailcopy";
                              }

                              mailitemEntryID = strsubject;

                              string tempFilePath = UserLogManagerUtility.RootDirectory + "\\" + strsubject + ".msg";

                              if (Directory.Exists(UserLogManagerUtility.RootDirectory) == false)
                              {
                                  Directory.CreateDirectory(UserLogManagerUtility.RootDirectory);
                              }
                              m.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG);

                          }
                          catch (Exception ex)
                          {

                          }

                          Outlook.MAPIFolder fp = (Outlook.MAPIFolder)m.Parent;
                          DoNotMoveInNonDocLib(mailitemEntryID, fp);

                      }
                      catch (Exception)
                      {
                          NonDocMoveReportItem(Item);
                      }

                      MessageBox.Show("You are attempting to move files to a non document library. This action is not supported.", "ITOPIA", MessageBoxButtons.OK, MessageBoxIcon.Information);

                      return;

                  }

                  if (frmUploadItemsListObject == null || (frmUploadItemsListObject != null && frmUploadItemsListObject.IsDisposed == true))
                  {
                      //frmUploadItemsListObject = new frmUploadItemsList();

                      // myCustomTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(frmUploadItemsListObject, "ITOPIA");
                      //myCustomTaskPane.Visible = true;

                      IAddCustomTaskPane();

                  }
                  //frmUploadItemsListObject.TopLevel = true;
                  //frmUploadItemsListObject.TopMost = true;

                  ////////////////////// frmUploadItemsListObject.Show();

                  try
                  {

                      //////
                      //////////
                      Outlook.MailItem oMailItem = (Outlook.MailItem)Item;
                      parentfolder = (Outlook.MAPIFolder)oMailItem.Parent;
                      try
                      {
                          mailitem = oMailItem;

                          mailitemEntryID = oMailItem.EntryID;

                          string strsubject = oMailItem.EntryID;
                          if (string.IsNullOrEmpty(strsubject))
                          {
                              strsubject = "tempomailcopy";
                          }

                          mailitemEntryID = strsubject;

                          string tempFilePath = UserLogManagerUtility.RootDirectory + "\\" + strsubject + ".msg";

                          if (Directory.Exists(UserLogManagerUtility.RootDirectory) == false)
                          {
                              Directory.CreateDirectory(UserLogManagerUtility.RootDirectory);
                          }
                          oMailItem.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG);

                      }
                      catch (Exception ex)
                      {

                      }

                      string fileName = string.Empty;
                      if (!string.IsNullOrEmpty(oMailItem.Subject))
                      {
                          //Replce any specila characters in subject
                          fileName = Regex.Replace(oMailItem.Subject, strMailSubjectReplcePattern, " ");
                          fileName = fileName.Replace(".", "_");
                      }

                      if (string.IsNullOrEmpty(fileName))
                      {
                          DateTime dtReceivedDate = Convert.ToDateTime(oMailItem.ReceivedTime);
                          fileName = "Untitled_" + dtReceivedDate.Day + "_" + dtReceivedDate.Month + "_" + dtReceivedDate.Year + "_" + dtReceivedDate.Hour + "_" + dtReceivedDate.Minute + "_" + dtReceivedDate.Millisecond;
                      }

                      UploadItemsData newUploadData = new UploadItemsData();
                      newUploadData.ElapsedTime = DateTime.Now;
                      newUploadData.UploadFileName = fileName;// oMailItem.Subject;
                      newUploadData.UploadFileExtension = ".msg";
                      newUploadData.UploadingMailItem = oMailItem;
                      newUploadData.UploadType = TypeOfUploading.Mail;
                      newUploadData.DisplayFolderName = folderName;
                      frmUploadItemsListObject.UploadUsingDelegate(newUploadData);
                      //Set dropped items is uploaded
                      /////////////////////////updated by Joy on 25.07.2012/////////////////////////////////
                      bool uploadStatus = frmUploadItemsListObject.IsSuccessfullyUploaded;
                      XMLLogOptions userOption = UserLogManagerUtility.GetUserConfigurationOptions();
                      if (uploadStatus == true)
                      {
                          // Globals.ThisAddIn.isTimerUploaded = true;
                          isDroppedItemUplaoded = true;

                          for (int i = 0; i <= activeDroppingFolder.Items.Count; i++)
                          {
                              try
                              {
                                  Outlook.MailItem me = (Outlook.MailItem)activeDroppingFolder.Items[i];

                                  if (me.EntryID == mailitemEntryID)
                                  {
                                      me.Categories.Remove(0);
                                      me.Categories = newCatName;
                                      me.Save();

                                      if (userOption.AutoDeleteEmails == true)
                                      {
                                          UserMailDeleteOption(mailitemEntryID, parentfolder);
                                      }
                                  }
                              }
                              catch (Exception ex)
                              {

                              }
                          }

                          frmUploadItemsListObject.lblPRStatus.Invoke(new updateProgresStatus(() =>
                          {
                              frmUploadItemsListObject.lblPRStatus.Text = Globals.ThisAddIn.no_of_t_item_uploaded.ToString() + " " + "of" + " " + Globals.ThisAddIn.no_of_pending_items_to_be_uploaded.ToString() + " " + "Uploaded";
                          }));
                          frmUploadItemsListObject.progressBar1.Invoke(new updateProgessBar(() =>
                          {
                              frmUploadItemsListObject.progressBar1.Value = (((Globals.ThisAddIn.no_of_t_item_uploaded * 100 / Globals.ThisAddIn.no_of_pending_items_to_be_uploaded)));
                          }));

                      }
                      else
                      {
                          isDroppedItemUplaoded = false;
                      }

                      /////////////////////////updated by Joy on 25.07.2012/////////////////////////////////
                  }
                  catch (Exception ex)
                  {
                      isDroppedItemUplaoded = MoveItemIsReportItem(Item);
                  }

                  try
                  {
                      if (isDroppedItemUplaoded == false)
                      {
                          //string tempName = oDocItem.Subject;
                          string tempName = string.Empty;
                          Outlook.DocumentItem oDocItem = (Outlook.DocumentItem)Item;

                          try
                          {

                              Outlook._MailItem myMailItem = (Outlook.MailItem)addinExplorer.Selection[1];
                              foreach (Outlook.Attachment oAttachment in myMailItem.Attachments)
                              {
                                  if (oAttachment.FileName == oDocItem.Subject)
                                  {
                                      tempName = oAttachment.FileName;
                                      tempName = tempName.Substring(tempName.LastIndexOf("."));
                                      oAttachment.SaveAsFile(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName);

                                      //Read file data to bytes
                                      //byte[] fileBytes = File.ReadAllBytes(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName);
                                      System.IO.FileStream Strm = new System.IO.FileStream(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                                      System.IO.BinaryReader reader = new System.IO.BinaryReader(Strm);
                                      byte[] fileBytes = reader.ReadBytes(Convert.ToInt32(Strm.Length));
                                      reader.Close();
                                      Strm.Close();

                                      //Replace any special characters are there in file name
                                      string fileName = Regex.Replace(oAttachment.FileName, strAttachmentReplacePattern, " ");

                                      //Add uplaod attachment item data to from list.
                                      UploadItemsData newUploadData = new UploadItemsData();
                                      newUploadData.UploadType = TypeOfUploading.Attachment;
                                      newUploadData.AttachmentData = fileBytes;
                                      newUploadData.DisplayFolderName = activeDroppingFolder.Name;

                                      if (fileName.Contains("."))
                                      {
                                          newUploadData.UploadFileName = fileName.Substring(0, fileName.LastIndexOf("."));
                                          newUploadData.UploadFileExtension = fileName.Substring(fileName.LastIndexOf("."));

                                          if (string.IsNullOrEmpty(newUploadData.UploadFileName.Trim()))
                                          {
                                              //check file name conatins empty add the date time
                                              newUploadData.UploadFileName = "Untitled_" + DateTime.Now.ToFileTime();

                                          }
                                      }

                                      //Add to form
                                      frmUploadItemsListObject.UploadUsingDelegate(newUploadData);
                                      //Set dropped mail attachment items is uploaded.
                                      isDroppedItemUplaoded = true;
                                      newUploadData = null;
                                      //oDocItem.Delete();
                                      break;
                                  }
                              }
                          }
                          catch (InvalidCastException ex)
                          {
                              //Set dropped mail attachment items is uploaded to false
                              isDroppedItemUplaoded = false;
                          }

                          if (isDroppedItemUplaoded == false)
                          {
                              tempName = oDocItem.Subject;
                              tempName = tempName.Substring(tempName.LastIndexOf("."));
                              oDocItem.SaveAs(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName, Type.Missing);

                              System.IO.FileStream Strm = new System.IO.FileStream(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                              System.IO.BinaryReader reader = new System.IO.BinaryReader(Strm);
                              byte[] fileBytes = reader.ReadBytes(Convert.ToInt32(Strm.Length));
                              reader.Close();
                              Strm.Close();

                              //Replace any special characters are there in file name
                              string fileName = Regex.Replace(oDocItem.Subject, strAttachmentReplacePattern, " ");

                              //Add uplaod attachment item data to from list.
                              UploadItemsData newUploadData = new UploadItemsData();
                              newUploadData.UploadType = TypeOfUploading.Attachment;
                              newUploadData.AttachmentData = fileBytes;
                              newUploadData.DisplayFolderName = activeDroppingFolder.Name;

                              if (fileName.Contains("."))
                              {
                                  newUploadData.UploadFileName = fileName.Substring(0, fileName.LastIndexOf("."));
                                  newUploadData.UploadFileExtension = fileName.Substring(fileName.LastIndexOf("."));

                                  if (string.IsNullOrEmpty(newUploadData.UploadFileName.Trim()))
                                  {
                                      //check file name conatins empty add the date time
                                      newUploadData.UploadFileName = "Untitled_" + DateTime.Now.ToFileTime();

                                  }
                              }

                              //Add to form
                              frmUploadItemsListObject.UploadUsingDelegate(newUploadData);
                              newUploadData = null;
                              //oDocItem.Delete();
                          }

                      }
                  }
                  catch (Exception ex)
                  {
                      //throw ex;
                      //////////////////////////////updated by Joy on 28.07.2012///////////////////////////////////
                      //  EncodingAndDecoding.ShowMessageBox("FolderItem Add Event_DocItem Conv", ex.Message, MessageBoxIcon.Error);
                      //////////////////////////////updated by Joy on 28.07.2012///////////////////////////////////
                  }

                  try
                  {
                      XMLLogOptions userOptions = UserLogManagerUtility.GetUserConfigurationOptions();

                      for (int i = 0; i <= parentfolder.Items.Count; i++)
                      {
                          try
                          {
                              Outlook.MailItem me = (Outlook.MailItem)parentfolder.Items[i];

                              if (me.EntryID == mailitemEntryID)
                              {
                                  ///////////////////////////modified by Joy on 10.08.2012////////////////////////////////////

                                  if (isDroppedItemUplaoded == true)
                                  {

                                      me.Categories.Remove(0);
                                      me.Categories = newCatName;
                                      me.Save();
                                      if (userOptions.AutoDeleteEmails == true)
                                      {
                                          UserMailDeleteOption(mailitemEntryID, parentfolder);
                                      }
                                      //parentfolder.Items.Remove(i);
                                  }
                                  ///////////////////////////modified by Joy on 10.08.2012////////////////////////////////////

                              }
                          }
                          catch (Exception)
                          {

                          }
                      }
                  }

                  catch (Exception)
                  {

                  }
                  if (!string.IsNullOrEmpty(mailitemEntryID))
                  {
                      if (ItemType == TypeOfMailItem.ReportItem)
                      {
                          UserReportItemDeleteOption(mailitemEntryID, parentfolder);
                      }
                      else
                      {
                          ///////////////////////////Updated by Joy on 16.08.2012....to be updated later///////////////////////////////
                          // UserMailDeleteOption(mailitemEntryID, parentfolder);
                          ///////////////////////////Updated by Joy on 16.08.2012....to be updated later///////////////////////////////
                      }
                  }

              }

              }
              catch (Exception ex)
              {
              EncodingAndDecoding.ShowMessageBox("Folder Item Add Event", ex.Message, MessageBoxIcon.Error);

              }

              //AddToUploadList(Item);
        }
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            CurrentVersion = Convert.ToInt32(Globals.ThisAddIn.Application.Version.Split('.')[0]);
            this.objExplorer = Globals.ThisAddIn.Application.ActiveExplorer();
            SuiteCRMClient.clsSuiteCRMHelper.InstallationPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SuiteCRMOutlookAddIn";
            this.settings = new clsSettings();
            if (this.settings.AutoArchive)
            {
                this.objExplorer.Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail);
                this.objExplorer.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend);
            }
            if (CurrentVersion < 14)
            {
                this.Application.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay);
                var menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;
                objSuiteCRMMenuBar2007 = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true);
                if (objSuiteCRMMenuBar2007 != null)
                {
                    objSuiteCRMMenuBar2007.Caption = "SuiteCRM";
                    this.btnArvive = (Office.CommandBarButton)this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                    this.btnArvive.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    this.btnArvive.Caption = "Archive";
                    this.btnArvive.Picture = RibbonImageHelper.Convert(Resources.SuiteCRM1);
                    this.btnArvive.Click += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnArchive_Click);
                    this.btnArvive.Visible = true;
                    this.btnArvive.BeginGroup = true;
                    this.btnArvive.TooltipText = "Archive selected emails to SuiteCRM";
                    this.btnArvive.Enabled = true;
                    this.btnSettings = (Office.CommandBarButton)this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                    this.btnSettings.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    this.btnSettings.Caption = "Settings";
                    this.btnSettings.Click += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnSettings_Click);
                    this.btnSettings.Visible = true;
                    this.btnSettings.BeginGroup = true;
                    this.btnSettings.TooltipText = "SuiteCRM Settings";
                    this.btnSettings.Enabled = true;
                    this.btnSettings.Picture = RibbonImageHelper.Convert(Resources.Settings);

                    objSuiteCRMMenuBar2007.Visible = true;
                }
            }
            else
            {
                //For Outlook version 2010 and greater
                //var app = this.Application;
                //app.FolderContextMenuDisplay += new Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHander(this.app_FolderContextMenuDisplay);
            }
            SuiteCRMAuthenticate();
        }
Example #51
0
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     //inspectors = this.Application.Inspectors;
     //inspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
     //AddMenuBar();
     currentExplorer = this.Application.ActiveExplorer();
     Outlook.Selection selecteditems = currentExplorer.Selection;
 }
Example #52
0
 //Create callback methods here. For more information about adding callback methods, visit http://go.microsoft.com/fwlink/?LinkID=271226
 public void Ribbon_Load(Office.IRibbonUI ribbonUI)
 {
     currentExplorer = Globals.ThisAddIn.Application.ActiveExplorer();
     currentExplorer.SelectionChange += new Outlook
         .ExplorerEvents_10_SelectionChangeEventHandler
         (CurrentExplorer_Event);
     addIn = Globals.ThisAddIn;
     this.ribbon = ribbonUI;
 }
        /// <summary>
        /// This event occures when this explorer has been closed.
        /// </summary>
        void _Explorer_ExplorerEvents_Event_Close()
        {
            // here release references to the explorer from memory.
            Outlook.ExplorerEvents_10_Event explorerEvents = _Explorer as Outlook.ExplorerEvents_10_Event;
            if (explorerEvents == null)
                return;

            explorerEvents.FolderSwitch -= new Outlook.ExplorerEvents_10_FolderSwitchEventHandler(_Explorer_FolderSwitch);
            explorerEvents.Close -= new Outlook.ExplorerEvents_10_CloseEventHandler(_Explorer_ExplorerEvents_Event_Close);
            _Explorer = null;

            // fire an event toinform the application that this explorer has been closed.
            if (ExplorerClosed == null)
                return;

            ExplorerClosed(this._Id);
        }
 /// <summary>
 /// The constructor
 /// </summary>
 /// <param name="activeExplorer">The Outlook active explorer containing the CommandBar(s).</param>
 public GnuPGCommandBar(Outlook.Explorer activeExplorer)
 {
     _explorer = activeExplorer;
 }
Example #55
0
        private void LinkSelectionChange()
        {
            _explorerReference = Application.ActiveExplorer();

            foreach (Outlook.Explorer Exp in Application.Explorers)
            {
                Exp.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(ThisAddIn_SelectionChange);
            }
        }