Beispiel #1
0
 private void permanentlyDeleteEmail(
     Microsoft.Office.Interop.Outlook.MailItem currMail)
 {
     Microsoft.Office.Interop.Outlook.Explorer currExplorer =
         Globals.ThisAddIn.Application.ActiveExplorer();
     Microsoft.Office.Interop.Outlook.Store store =
         currExplorer.CurrentFolder.Store;
     Microsoft.Office.Interop.Outlook.MAPIFolder deletedItemsFolder =
         store.GetRootFolder().Folders[DELETED_ITEMS_FOLDER_NAME];
     Microsoft.Office.Interop.Outlook.MailItem movedMail =
         currMail.Move(deletedItemsFolder);
     movedMail.Subject = movedMail.Subject + " ";
     movedMail.Save();
     movedMail.Delete();
 }
Beispiel #2
0
        /**
         *
         * Moves a specified email to a specified destination folder by name.
         *
         */

        private Microsoft.Office.Interop.Outlook.MailItem moveEmail(
            Microsoft.Office.Interop.Outlook.MailItem currMail,
            string destinationFolderName)
        {
            Microsoft.Office.Interop.Outlook.Explorer currExplorer =
                Globals.ThisAddIn.Application.ActiveExplorer();

            Microsoft.Office.Interop.Outlook.Store store =
                currExplorer.CurrentFolder.Store;

            // Move the current email to User's selected Mail Box...
            Microsoft.Office.Interop.Outlook.MAPIFolder destFolder =
                store.GetRootFolder().Folders[destinationFolderName];

            return(currMail.Move(destFolder));
        }
        protected void populateAddressListFromOutlook()
        {
            DateTime startDate, endDate;

            endDate   = DateTime.Today;
            startDate = endDate.AddDays(-30);

            // app = new Microsoft.Office.Interop.Outlook.Application(); - this line will create problem with Outlook 2013 sometimes
            app = this.Application;
            //}
            ns = app.GetNamespace("MAPI");


            calendar = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);

            String StringToCheck = "";

            StringToCheck = "[Start] >= " + "\"" + startDate.ToString().Substring(0, startDate.ToString().IndexOf(" ")) + "\""
                            + " AND [End] <= \"" + endDate.ToString().Substring(0, endDate.ToString().IndexOf(" ")) + "\"";


            Microsoft.Office.Interop.Outlook.Items oItems = (Microsoft.Office.Interop.Outlook.Items)calendar.Items;
            Microsoft.Office.Interop.Outlook.Items restricted;

            oItems.Sort("[Start]", false);
            oItems.IncludeRecurrences = true;

            restricted = oItems.Restrict(StringToCheck);
            restricted.Sort("[Start]", false);

            restricted.IncludeRecurrences = true;
            Microsoft.Office.Interop.Outlook.AppointmentItem oAppt = (Microsoft.Office.Interop.Outlook.AppointmentItem)restricted.GetFirst();

            Dictionary <String, String> comboDict = new Dictionary <string, string>();

            comboDict.Add("ALL", "ALL");

            //Loop through each appointment item to find out the unique recipient list and add to the combo box
            while (oAppt != null)
            {
                oAppt = (Microsoft.Office.Interop.Outlook.AppointmentItem)restricted.GetNext();

                if (oAppt != null)
                {
                    foreach (Microsoft.Office.Interop.Outlook.Recipient rcp in oAppt.Recipients)
                    {
                        //Display the email id in bracket along with the name in case the name rcp.Name does not contain the email address
                        //This will help in situtation where the the same recipient with multiple emails address need to be distinguised
                        String recpDisplayString = rcp.Name.IndexOf("@") < 0 ? rcp.Name + "(" + rcp.Address + ")" : rcp.Name;

                        if (!comboDict.ContainsKey(recpDisplayString))
                        {
                            comboDict.Add(recpDisplayString, recpDisplayString);
                            if (recpDisplayString != null && !emailNameMappingDict.ContainsKey(recpDisplayString))
                            {
                                emailNameMappingDict.Add(recpDisplayString, rcp.Address != null ? rcp.Address : rcp.Name);
                            }
                            if (rcp.Name != null && !MOM_Form.autoCompleteList.Contains(recpDisplayString))
                            {
                                MOM_Form.autoCompleteList.Add(recpDisplayString);
                            }
                        }
                    }
                }
            }

            //listBox_AddrList.DataSource = new BindingSource(comboDict, null);
            //listBox_AddrList.DisplayMember = "Value";
            //listBox_AddrList.ValueMember = "Key";
            //listBox_AddrList.SelectedValue = "ALL";

            populateAutoCompleteList(startDate, endDate);
        }
        protected void populateAutoCompleteList(DateTime startDate, DateTime endDate)
        {
            inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
            sentFolder  = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderSentMail);
            String StringToCheck = "";

            StringToCheck = "[Received] >= " + "\"" + startDate.ToString().Substring(0, startDate.ToString().IndexOf(" ")) + "\""
                            + " AND [Received] <= \"" + endDate.ToString().Substring(0, endDate.ToString().IndexOf(" ")) + "\"";


            Microsoft.Office.Interop.Outlook.Items oItemsInbox   = (Microsoft.Office.Interop.Outlook.Items)inboxFolder.Items;
            Microsoft.Office.Interop.Outlook.Items oItemsSentBox = (Microsoft.Office.Interop.Outlook.Items)sentFolder.Items;

            Microsoft.Office.Interop.Outlook.Items    restricted;
            Microsoft.Office.Interop.Outlook.MailItem mailObject = null;
            //First scan the inbox items for unique contacts
            oItemsInbox.Sort("[Received]", false);
            oItemsInbox.IncludeRecurrences = true;
            restricted = oItemsInbox.Restrict(StringToCheck);
            restricted.Sort("[Received]", false);

            restricted.IncludeRecurrences = true;

            Object emailItem = null;

            if (restricted.GetFirst() is Microsoft.Office.Interop.Outlook.MailItem)
            {
                emailItem = (Microsoft.Office.Interop.Outlook.MailItem)restricted.GetFirst();
            }

            while (emailItem != null)
            {
                if (emailItem is Microsoft.Office.Interop.Outlook.MailItem)
                {
                    mailObject = (Microsoft.Office.Interop.Outlook.MailItem)emailItem;
                }

                if (!MOM_Form.autoCompleteList.Contains(mailObject.SenderEmailAddress.Trim()))
                {
                    MOM_Form.autoCompleteList.Add(mailObject.SenderEmailAddress.Trim());
                }

                emailItem = restricted.GetNext();
            }

            StringToCheck = "[SentOn] >= " + "\"" + startDate.ToString().Substring(0, startDate.ToString().IndexOf(" ")) + "\""
                            + " AND [SentOn] <= \"" + endDate.ToString().Substring(0, endDate.ToString().IndexOf(" ")) + "\"";

            oItemsSentBox.Sort("[SentOn]", false);
            oItemsSentBox.IncludeRecurrences = true;
            restricted = oItemsSentBox.Restrict(StringToCheck);
            restricted.Sort("[SentOn]", false);

            restricted.IncludeRecurrences = true;
            if (restricted.GetFirst() is MailItem)
            {
                emailItem = (Microsoft.Office.Interop.Outlook.MailItem)restricted.GetFirst();
            }

            while (emailItem != null)
            {
                if (emailItem is Microsoft.Office.Interop.Outlook.MailItem)
                {
                    mailObject = (Microsoft.Office.Interop.Outlook.MailItem)emailItem;
                }

                if (!MOM_Form.autoCompleteList.Contains(mailObject.SenderEmailAddress.Trim()))
                {
                    MOM_Form.autoCompleteList.Add(mailObject.SenderEmailAddress.Trim());
                }

                emailItem = restricted.GetNext();
            }
        }
Beispiel #5
0
        /// <summary>
        /// code in this section written by Joy
        /// this method fires by the timer before uploading the mail items
        /// </summary>
        /// <param name="ClipboardContent"></param>
        /// <param name="Target"></param>
        /// <param name="Cancel"></param>
        void addinExplorer_beforeMovingToMappedFolder(object ClipboardContent, Microsoft.Office.Interop.Outlook.MAPIFolder Target, bool Cancel)
        {
            if (isTimerUploadRunning == false && isuploadRunning == false)
            {
                try
                {

                    AddfFolderinSessionMapi();

                    IsUrlIsTyped = false;
                    currentFolderSelected = Target.Name;
                    currentFolderSelectedGuid = Target.EntryID;

                    myTargetFolder = Target;
                    if (IsUploadingFormIsOpen == true)
                    {
                        if (Globals.ThisAddIn.frmlistObject != null)
                        {
                            Globals.ThisAddIn.frmlistObject.Invoke(new progressUpdater(()=>
                                 {
                            frmlistObject.progressBar1.Value = frmlistObject.progressBar1.Minimum;
                            frmlistObject.lblPRStatus.Text = "";
                                 }));
                        }

                        //frmMessageWindow objMessage = new frmMessageWindow();
                        //objMessage.DisplayMessage = "Please check the uploading form. Form is still open.";
                        //objMessage.TopLevel = true;
                        //objMessage.TopMost = true;
                        //objMessage.ShowDialog();
                        //objMessage.Dispose();
                        ////EncodingAndDecoding.ShowMessageBox("", "Please check the uploading form. Form is still open.", MessageBoxIcon.Warning);
                        //Cancel = true;
                        //return;

                    }

                    //Check  dropping item is from browser or not

                    if (ClipboardContent.GetType().Name == "String")
                    {
                        //Set active folder as TargetFolder
                        this.Application.ActiveExplorer().SelectFolder(Target);

                        //'Cerate instance
                        frmSPSiteConfigurationObject = new frmSPSiteConfiguration();
                        //Get the drop url

                        frmSPSiteConfigurationObject.URL = Convert.ToString(ClipboardContent);

                        frmSPSiteConfigurationObject.ShowDialog();
                        if (frmSPSiteConfigurationObject.IsConfigureCompleted)
                        {
                            //Save the details in log proeprties object
                            XMLLogProperties xLogProperties = frmSPSiteConfigurationObject.FolderConfigProperties;

                            Outlook.MAPIFolder newFolder = null;
                            bool result = CreateFolderInOutLookSideMenu(xLogProperties.DisplayFolderName, xLogProperties.SiteURL, out newFolder, Target);

                            Cancel = true;
                            if (result == true && newFolder != null)
                            {

                                //Set new folder location
                                xLogProperties.OutlookFolderLocation = newFolder.FolderPath;
                                //Create node in xml file
                                UserLogManagerUtility.CreateXMLFileForStoringUserCredentials(xLogProperties);

                                MAPIFolderWrapper omapi = null;
                                if (string.IsNullOrEmpty(xLogProperties.DocumentLibraryName) == true)
                                {
                                    //Doc name is empty means Folder is not mapped with Doc Lib
                                    omapi = new MAPIFolderWrapper(ref  newFolder, addinExplorer, false);
                                }
                                else
                                {
                                    omapi = new MAPIFolderWrapper(ref newFolder, addinExplorer, true);
                                }
                                omapi.AttachedFolder.WebViewURL = ListWebClass.WebViewUrl(omapi.AttachedFolder.WebViewURL);
                                myFolders.Add(omapi);

                            }

                        }
                        else
                        {
                            frmSPSiteConfigurationObject.Close();
                            Cancel = true;
                        }
                    }
                    else
                    {

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

                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// <c>addinExplorer_BeforeItemPaste</c> Event Handler
        /// Fires when any item is dragged and dropped to an outlook Folder
        /// </summary>
        /// <param name="ClipboardContent"></param>
        /// <param name="Target"></param>
        /// <param name="Cancel"></param>
        void addinExplorer_BeforeItemPaste(ref object ClipboardContent, Microsoft.Office.Interop.Outlook.MAPIFolder Target, ref bool Cancel)
        {
            ///code written by Joy///
              ///checks if any upload is running
            if (isuploadRunning == true||isTimerUploadRunning==true||isMoveRunning==true||isCopyRunninng==true)
            {
                frmMessageWindow objMessage = new frmMessageWindow();
                objMessage.DisplayMessage = "Your uploads are still running.Please wait for sometime.";
                objMessage.TopLevel = true;
                objMessage.TopMost = true;
                objMessage.ShowDialog();
                objMessage.Dispose();
                //EncodingAndDecoding.ShowMessageBox("", "Please check the uploading form. Form is still open.", MessageBoxIcon.Warning);
                Cancel = true;
                return;

            }
            else
            {
                try
                {
                    ///all code in this section written by joy
                    ///retrieves the mail items from the Selection and set the progressbar value to default

                    Outlook.MailItem mailitem;
                    no_of_items_copied = 0;

                    Outlook.Application myApplication = Globals.ThisAddIn.Application;
                    Outlook.Explorer myActiveExplorer = (Outlook.Explorer)myApplication.ActiveExplorer();

                    ///retrieves the mail items from the Selection
                    oselection = myActiveExplorer.Selection;

                    no_of_items_to_be_uploaded = oselection.Count;

                    AddfFolderinSessionMapi();

                    IsUrlIsTyped = false;
                    currentFolderSelected = Target.Name;
                    currentFolderSelectedGuid = Target.EntryID;

                    myTargetFolder = Target;

                    if (IsUploadingFormIsOpen == true)
                    {
                        if (Globals.ThisAddIn.frmlistObject != null)
                        {
                            ///set the progressbar value to default
                            frmlistObject.progressBar1.Value = frmlistObject.progressBar1.Minimum;
                            frmlistObject.lblPRStatus.Text = "";
                        }
                        //frmUploadItemsList frmUplList = new frmUploadItemsList();
                        //frmUplList.progressBar1.Value = frmUplList.progressBar1.Minimum;
                        //frmUplList.lblPRStatus.Text = "";
                        //frmUplList.Refresh();
                        //frmUplList.Visible = false;
                        //frmUplList.Dispose();

                    }

                    //Check  dropping item is from browser or not

                    if (ClipboardContent.GetType().Name == "String")
                    {
                        //Set active folder as TargetFolder
                        this.Application.ActiveExplorer().SelectFolder(Target);

                        //'Cerate instance
                        frmSPSiteConfigurationObject = new frmSPSiteConfiguration();
                        //Get the drop url

                        frmSPSiteConfigurationObject.URL = Convert.ToString(ClipboardContent);

                        frmSPSiteConfigurationObject.ShowDialog();
                        if (frmSPSiteConfigurationObject.IsConfigureCompleted)
                        {
                            //Save the details in log proeprties object
                            XMLLogProperties xLogProperties = frmSPSiteConfigurationObject.FolderConfigProperties;

                            Outlook.MAPIFolder newFolder = null;
                            bool result = CreateFolderInOutLookSideMenu(xLogProperties.DisplayFolderName, xLogProperties.SiteURL, out newFolder, Target);

                            Cancel = true;
                            if (result == true && newFolder != null)
                            {

                                //Set new folder location
                                xLogProperties.OutlookFolderLocation = newFolder.FolderPath;
                                //Create node in xml file
                                UserLogManagerUtility.CreateXMLFileForStoringUserCredentials(xLogProperties);

                                MAPIFolderWrapper omapi = null;
                                if (string.IsNullOrEmpty(xLogProperties.DocumentLibraryName) == true)
                                {
                                    //Doc name is empty means Folder is not mapped with Doc Lib
                                    omapi = new MAPIFolderWrapper(ref  newFolder, addinExplorer, false);
                                }
                                else
                                {
                                    omapi = new MAPIFolderWrapper(ref newFolder, addinExplorer, true);
                                }
                                omapi.AttachedFolder.WebViewURL = ListWebClass.WebViewUrl(omapi.AttachedFolder.WebViewURL);
                                myFolders.Add(omapi);

                            }

                        }
                        else
                        {
                            frmSPSiteConfigurationObject.Close();
                            Cancel = true;
                        }
                    }
                    else
                    {

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

                }
            }
        }
Beispiel #7
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;
        }
Beispiel #8
0
        /// <summary>
        /// code written by Joy
        /// moves or copies mail items to the selected mapped folder
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren() == true)
            {
                if (ThisAddIn.IsUploadingFormIsOpen == true)
                {
                    if (Globals.ThisAddIn.frmlistObject != null)
                    {
                        Globals.ThisAddIn.frmlistObject.progressBar1.Value = Globals.ThisAddIn.frmlistObject.progressBar1.Minimum;
                        Globals.ThisAddIn.frmlistObject.lblPRStatus.Text = "";
                    }

                }
                string selected_mapiFolderName = cmbOptions.Text;
                this.Close();
                if (Globals.ThisAddIn.copy_button_clicked == true)
                {
                    OutlookObj = Globals.ThisAddIn.Application;
                    outlookNameSpace = OutlookObj.GetNamespace("MAPI");
                    olInBox = outlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
                    parentFolder = (Microsoft.Office.Interop.Outlook.MAPIFolder)olInBox.Parent;
                    string mappedFolderName = cmbOptions.SelectedItem.ToString();
                    mappedFolder = MAPIFolderWrapper.GetFolder(parentFolder, mappedFolderName);
                    Outlook.MailItem mItem;
                    Outlook.MailItem copyMail;
                    Globals.ThisAddIn.isCopyRunninng = true;
                    foreach (Object obj in Globals.ThisAddIn.copySelected)
                    {
                        if (obj is Outlook.MailItem)
                        {
                            mItem = (Outlook.MailItem)obj;
                            copyMail = mItem.Copy() as Outlook.MailItem;
                            copyMail.Move(mappedFolder);
                            //doBackGroundUpload(mItem);
                        }
                    }
                }
                else if (Globals.ThisAddIn.move_button_clicked == true)
                {

                        OutlookObj = Globals.ThisAddIn.Application;
                        outlookNameSpace = OutlookObj.GetNamespace("MAPI");
                        olInBox = outlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
                        parentFolder = (Microsoft.Office.Interop.Outlook.MAPIFolder)olInBox.Parent;
                        string mappedFolderName = cmbOptions.SelectedItem.ToString();
                        mappedFolder = MAPIFolderWrapper.GetFolder(parentFolder, mappedFolderName);
                        Outlook.MailItem mItem;
                        Globals.ThisAddIn.isMoveRunning = true;
                        foreach (Object obj in Globals.ThisAddIn.moveSelected)
                        {
                            if (obj is Outlook.MailItem)
                            {
                                mItem = (Outlook.MailItem)obj;
                                mItem.Move(mappedFolder);
                                //doBackGroundUpload(mItem);
                            }
                        }

                }
            }
            else
                return;
        }