Example #1
0
        private void btnFolderSelect_Click(object sender, EventArgs e)
        {
            object missing = Missing.Value;

            //get the Outlook Application Object
            Outlook.Application outlookApplication = new Outlook.Application();

            //get the namespace object
            Outlook.NameSpace nameSpace = outlookApplication.GetNamespace("MAPI");

            //Logon to Session, here we use an already opened Outlook session
            nameSpace.Logon(missing, missing, false, false);

            //get the InboxFolder
            Outlook.MAPIFolder Folder = nameSpace.PickFolder();
            if (Folder != null)
            {
                txtMoveToFolder.Text           = Folder.Name;
                this.Profile.MoveFolderName    = Folder.EntryID;
                this.Profile.MoveFolderStoreId = Folder.StoreID;
            }

            //release used resources
            if (Folder != null)
            {
                Marshal.ReleaseComObject(Folder);
            }

            //logof from namespace
            nameSpace.Logoff();

            //release resources
            Marshal.ReleaseComObject(nameSpace);
            Marshal.ReleaseComObject(outlookApplication.Application);
        }
        private void ButtonSendPath_Click(object sender, EventArgs e)
        {
            Outlook.NameSpace  outlookNameSpace = Globals.ThisAddIn.Application.GetNamespace("MAPI");
            Outlook.MAPIFolder pickedFolder     = outlookNameSpace.PickFolder();
            string             folderPath;

            if (pickedFolder.FolderPath is object)
            {
                folderPath = pickedFolder.FolderPath;
                if (folderPath.StartsWith(@"\\"))
                {
                    folderPath = folderPath.Remove(0, 2);
                }
                Log.Message("FolderPath : " + folderPath);
            }
            else
            {
                folderPath = "";
            }

            LabelSendPathValue.Text = folderPath;
            contact.SentPath        = folderPath;

            if (pickedFolder is object)
            {
                Marshal.ReleaseComObject(pickedFolder);
            }
            if (outlookNameSpace is object)
            {
                Marshal.ReleaseComObject(outlookNameSpace);
            }
        }
Example #3
0
        public MailTable IndexSinglePst()
        {
            Microsoft.Office.Interop.Outlook.Application otlApplication = new Microsoft.Office.Interop.Outlook.Application();
            try
            {
                Outlook.NameSpace otlNameSpace = otlApplication.GetNamespace("MAPI");

                Outlook.Store      otlStore = otlNameSpace.PickFolder().Store;
                System.IO.FileInfo fi       = new System.IO.FileInfo(otlStore.FilePath);
                this.mailTable = new MailTable((new System.IO.FileInfo(otlStore.FilePath)).Name);
                this.mailTable.ModifiedData = fi.FullName + fi.Length.ToString();
                //this.mailTable.BaseTable = GMS.MailTable.getTable(this.mailTable.BaseTable, basetable.Select("StoreID<>'"+otlStore.StoreID.ToString()+"'"));
                try
                {
                    analyseFolder((Outlook.Folder)otlStore.GetRootFolder());
                }
                catch
                {
                }
            }



            catch
            {
            }
            finally
            {
                otlApplication = null;
            }

            return(this.mailTable);
        }
Example #4
0
 private void saveSend_Click(object sender, RibbonControlEventArgs e)
 {
     Outlook.Application application = new Outlook.Application();
     Outlook.Explorer    explorer    = application.ActiveExplorer();
     Outlook.Inspector   inspector   = application.ActiveInspector();
     Outlook._MailItem   mailItem    = inspector.CurrentItem;
     Outlook.NameSpace   nameSpace   = application.GetNamespace("MAPI");
     Outlook.Folder      folder      = (Outlook.Folder)nameSpace.PickFolder();
     mailItem.SaveSentMessageFolder = folder;
     mailItem.GetInspector.Activate();
     System.Windows.Forms.SendKeys.SendWait("%S");
 }
        private void ButtonDeliveryPath_Click(object sender, EventArgs e)
        {
            Outlook.NameSpace  outlookNameSpace = Globals.ThisAddIn.Application.GetNamespace("MAPI");
            Outlook.MAPIFolder pickedFolder     = outlookNameSpace.PickFolder();
            string             folderPath;

            if (pickedFolder.FolderPath is object)
            {
                folderPath = pickedFolder.FolderPath;
                if (folderPath.StartsWith(@"\\"))
                {
                    folderPath = folderPath.Remove(0, 2);
                }
            }
            else
            {
                folderPath = "";
            }

            LabelDeliveryPath.Text = folderPath;
            LabelReadPath.Text     = folderPath;
            contact.InboxPath      = folderPath;


            if (contact.SamePath)
            {
                GetSamePath();
            }

            if (pickedFolder is object)
            {
                Marshal.ReleaseComObject(pickedFolder);
            }
            if (outlookNameSpace is object)
            {
                Marshal.ReleaseComObject(outlookNameSpace);
            }
        }