//private static System.Threading.Timer timer; public static XLant.XLVirtualCabinet.BondResult IndexEmail(Outlook.MailItem email, string folder) { try { XLMain.Client selectClient = new XLMain.Client(); selectClient = GetClient(email); //Add CRMID to email for later use. UpdateParameter("CrmID", selectClient.crmID, email); //Collect data for indexing XLMain.Staff user = XLMain.Staff.StaffFromUser(Environment.UserName); string docPath = TempSave(email); string docDate = DateTime.Now.ToString("dd/MM/yyyy"); //take a guess at the status string status = ""; string desc = email.Subject; if (folder.Contains("Inbox")) { status = "External"; docDate = CheckDate(email.ReceivedTime); } else if (folder.Contains("Sent")) { status = "Sent"; docDate = CheckDate(email.SentOn); } else { status = "Draft"; docDate = CheckDate(DateTime.Now); } 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 XLVirtualCabinet.BondResult outcome = indexForm.outcome; //add client to recent list AddClienttoRecent(selectClient); return(outcome); } catch (Exception ex) { MessageBox.Show("Unable to index e-mail"); XLtools.LogException("IndexEmail", ex.ToString()); return(null); } }
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"); } }