public static void QuickIndex(Outlook.MailItem email, string folder) { try { XLant.XLVirtualCabinet.BondResult outcome = IndexEmail(email, folder); if (outcome.ExitCode != 0) { MessageBox.Show("Unable to index document, please index manually. Error code: " + outcome.ExitCode.ToString() + "-" + outcome.StandardOutput.ToString()); } else { //update the tick box and category UpdateVCTick(email); //delete email from temp directory if (File.Exists(outcome.DocPath)) { File.Delete(outcome.DocPath); } } } catch (Exception ex) { MessageBox.Show("Unable to index email"); XLtools.LogException("QuickIndex", ex.ToString()); } }
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()); } }
public static void IndexDraft(Outlook.MailItem email) { try { XLant.XLVirtualCabinet.BondResult outcome = IndexEmail(email, "Draft"); if (outcome.ExitCode != 0) { MessageBox.Show("Unable to index document, please index manually. Error code: " + outcome.ExitCode.ToString() + "-" + outcome.StandardOutput.ToString()); } else { UpdateVCTick(email); // As the filing has been successfull, get the FileId returned from Bond via the Standard Output string fileid = Regex.Match(outcome.StandardOutput, @"\d+").ToString(); string folderpath = XLtools.TempPath(); string commandfilepath = ""; commandfilepath = folderpath + "\\" + (String.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now)) + ".bond"; StreamWriter commandfile = new StreamWriter(commandfilepath, false, System.Text.Encoding.Default); commandfile.WriteLine("<<MODE=EDIT>>"); commandfile.WriteLine("<<INDEX01=" + fileid + ">>"); commandfile.WriteLine("<<OPENDOCUMENT=FALSE>>"); commandfile.Flush(); commandfile.Close(); // Call Bond to check out the document XLVirtualCabinet.BondResult result = XLVirtualCabinet.LaunchCabi(commandfilepath, false); // Dispose of the command file object commandfile.Dispose(); // Look for the file in the edited documents folder based on the FileId List <string> msgfile = new List <string>(); string[] Files = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Virtual Cabinet\\Edited documents"); int FilesCount = Files.Length; // Collect all the entries which match the fileID for (int i = 0; i < FilesCount; i++) { string f = Files[i].ToString(); if (Path.GetFileName(f).StartsWith(fileid + "-")) { msgfile.Add(f); } } if (msgfile.Count != 1) { Exception exception = new Exception("Unable to find the mail message. Your file has been indexed but could not have the file ID added."); } else { // Add the Virtual Cabinet FileId to the Subject of the email (still open on screen) // UserProperties and Custom Headers do not persist, so using something that does. Body could be another option. XLOutlook.UpdateParameter("VCFileID", fileid, email); //email.Subject = email.Subject + @" FileId:" + fileid.ToString(); // Save the MailItem email.Save(); // Save the email in the default MSG format if (File.Exists(msgfile[0])) { File.Delete(msgfile[0]); } email.SaveAs(msgfile[0]); // Create a command file to save the document as a new version based on the FileId commandfilepath = folderpath + "\\" + (String.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now)) + ".bond"; commandfile = new StreamWriter(commandfilepath, false, System.Text.Encoding.Default); commandfile.WriteLine("<<MODE=SAVE>>"); commandfile.WriteLine("<<INDEX01=" + fileid + ">>"); commandfile.Flush(); commandfile.Close(); // Call Bond to save the email back to VC result = XLVirtualCabinet.LaunchCabi(commandfilepath, false); // Dispose of the command file object commandfile.Dispose(); // Close the email in Outlook to prevent further changes that won't be saved to VC email.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olSave); // Delete the email from the Drafts folder in Outlook email.UnRead = false; email.Delete(); } } } catch (Exception ex) { MessageBox.Show("Unable to index draft email"); XLtools.LogException("IndexDraft", ex.ToString()); } }