public static void MultiQuickIndex(Outlook.MailItem email, string folder)
        {
            try
            {
                XLant.XLVirtualCabinet.BondResult outcome = IndexEmail(email, folder);
                // As the filing has been successfull, get the FileId returned from Bond via the Standard Output
                if (outcome.ExitCode == 0)
                {
                    string fileid = Regex.Match(outcome.StandardOutput, @"\d+").ToString();
                    XLVirtualCabinet.FileInfo info = XLVirtualCabinet.FileIndex(fileid);
                    DialogResult result            = MessageBox.Show("Do you want to index another copy", "Index", MessageBoxButtons.YesNo);
                    while (result == DialogResult.Yes)
                    {
                        XLForms.ClientForm myForm = new ClientForm();
                        myForm.ShowDialog();
                        XLMain.Client client = myForm.selectedClient;
                        //update the cabinet based on the new client
                        string cabinet = XLVirtualCabinet.FileStore(client.manager.office, client.department);
                        info.Cabinet = cabinet;
                        //update the client field
                        foreach (XLVirtualCabinet.IndexPair pair in info.Indexes)
                        {
                            if (pair.index == "INDEX02")
                            {
                                pair.value = client.clientcode + " - " + client.name;
                            }
                        }
                        outcome = XLVirtualCabinet.IndexDocument(outcome.DocPath, info);

                        if (outcome.ExitCode == 0)
                        {
                            result = MessageBox.Show("Do you want to index another copy", "Index", MessageBoxButtons.YesNo);
                            continue;
                        }
                        else
                        {
                            MessageBox.Show("Unable to index document, please index manually.  Error code: " + outcome.ExitCode.ToString() + "-" + outcome.StandardOutput.ToString());
                            break;
                        }
                    }
                    //update the tick box and category
                    UpdateVCTick(email);
                    //delete email from temp directory
                    if (File.Exists(outcome.DocPath))
                    {
                        File.Delete(outcome.DocPath);
                    }
                }
                else
                {
                    Exception e = new Exception("Unable to index");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to index email");
                XLtools.LogException("MultiQuickIndex", ex.ToString());
            }
        }
        private void IndexBtn_Click(object sender, EventArgs e)
        {
            string folder   = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\XLant\\temp\\";
            string tempPath = folder + "temp.msg";

            email.SaveAs(tempPath);

            string cabinet   = XLVirtualCabinet.FileStore(client.office, client.department);
            string clientStr = client.clientcode + " - " + client.name;
            string status    = "";

            if (email.ReceivedTime != null)
            {
                status = "External";
            }
            else if (email.SentOn != null)
            {
                status = "Sent";
            }
            else
            {
                status = "Draft";
            }
            XLMain.Staff toBe    = (XLMain.Staff)ToBeActionDDL.SelectedItem;
            string       desc    = DescTB.Text;
            string       section = "";

            if (client.department != "INS")
            {
                section = "Correspondence";
            }
            else
            {
                section = FileSectionDDL.SelectedItem.ToString();
            }
            //Launch the index process and collect the result
            XLVirtualCabinet.BondResult outcome = XLVirtualCabinet.IndexDocument(tempPath, cabinet, clientStr, status, toBe.name, section, desc);

            //close the dialog in any event.
            this.Close();
        }
        private void IndexBtn_Click(object sender, EventArgs e)
        {
            string fullPath       = docPath;
            string cabinet        = XLVirtualCabinet.FileStore(client.manager.office, client.department);
            string clientStr      = client.clientcode + " - " + client.name;
            string toBeActionedBy = null;

            if (ToBeActionDDL.SelectedValue == null)
            {
                toBeActionedBy = "";
            }
            else
            {
                XLMain.EntityCouplet toBe = (XLMain.EntityCouplet)ToBeActionDDL.SelectedItem;
                toBeActionedBy = toBe.name;
            }
            //collect information from the two optional ddls use whether they are visible or not to acsertain whether
            //to include them - They may not be visible but still hold data.
            XLVirtualCabinet.IndexPair list1Data = new XLVirtualCabinet.IndexPair();
            XLVirtualCabinet.IndexPair list2Data = new XLVirtualCabinet.IndexPair();
            if (ListDDL1.Visible)
            {
                list1Data.index = list1.index;
                list1Data.value = ListDDL1.Text;
            }
            if (ListDDL2.Visible)
            {
                list2Data.index = list2.index;
                list2Data.value = ListDDL2.Text;
            }

            string desc    = DescTB.Text;
            string section = "";

            section = FileSectionDDL.SelectedItem.ToString();
            //Launch the index process and collect the result
            outcome = XLVirtualCabinet.IndexDocument(fullPath, cabinet, clientStr, status, toBeActionedBy, section, desc, docDate, list1Data, list2Data);

            this.Close();
        }
        public static void IndexAttachments(Outlook.MailItem email)
        {
            if (email.Attachments.Count > 0)
            {
                XLVirtualCabinet.BondResult outcome = new XLVirtualCabinet.BondResult();
                string fileid  = "";
                string docPath = "";
                XLVirtualCabinet.FileInfo info = new XLVirtualCabinet.FileInfo();
                for (int i = 1; i <= email.Attachments.Count; i++)
                {
                    string folder = XLtools.TempPath();
                    if (i == 1)
                    {
                        email.Attachments[i].SaveAsFile(folder + email.Attachments[i].FileName);
                        XLMain.Client selectClient = GetClient(email);
                        //Collect data for indexing
                        XLMain.Staff user = XLMain.Staff.StaffFromUser(Environment.UserName);
                        docPath = folder + email.Attachments[i].FileName;
                        string docDate = DateTime.Now.ToString("dd/MM/yyyy");
                        string status  = "External";
                        string desc    = email.Attachments[i].FileName;
                        if (XLantRibbon.staff.Count == 0)
                        {
                            XLantRibbon.staff = XLMain.Staff.AllStaff();
                        }
                        VCForm indexForm = new VCForm(user, selectClient, docPath, desc, status, docDate, "blank", XLantRibbon.staff);
                        indexForm.ShowDialog();
                        //collect result from form
                        outcome = indexForm.outcome;

                        //get the details of the file.
                        fileid = Regex.Match(outcome.StandardOutput, @"\d+").ToString();
                        info   = XLVirtualCabinet.FileIndex(fileid);

                        //add client to recent list
                        AddClienttoRecent(selectClient);
                    }
                    else
                    {
                        //save the next file
                        email.Attachments[i].SaveAsFile(folder + email.Attachments[i].FileName);
                        docPath = folder + email.Attachments[i].FileName;

                        foreach (XLVirtualCabinet.IndexPair pair in info.Indexes)
                        {
                            if (pair.index.ToUpper() == "INDEX03")
                            {
                                string d = email.Attachments[i].FileName;
                                //generate form for the description to be altered
                                SingleDataCaptureForm myForm = new SingleDataCaptureForm("Input Description", "Enter Description", d);
                                myForm.ShowDialog();
                                if (myForm.result == DialogResult.Cancel)
                                {
                                    continue;
                                }
                                else
                                {
                                    pair.value = myForm.data;
                                }
                            }
                        }
                        outcome = XLVirtualCabinet.IndexDocument(docPath, info);
                    }
                }
                MessageBox.Show("All Attachments Saved");
            }
        }