private void LoadConversation(String FilePath) { LyncHistoryFile lhf = new LyncHistoryFile(); lhf.ReadFromFile(FilePath); HTMLViewer.DocumentText = lhf._Guts.HTML1; }
private void btnUploadConv_Click(object sender, EventArgs e) { FSWatch.EnableRaisingEvents = false; ImportProgressDialog ipd = new ImportProgressDialog(); AddOwnedForm(ipd); //ipd.Parent = this; //if (listFiles.SelectedItems.Count != 0) //{ ipd.Show(); int FileCounter = 0; String[] FileList = Directory.GetFiles(HistorySpoolerPath); int FileCount = FileList.Count(); ipd.prgImportProgress.Maximum = FileCount; foreach (String HistFile in FileList) { FileCounter++; FileInfo fi = new FileInfo(HistFile); ipd.prgImportProgress.Value = FileCounter; ipd.lblProgress.Text = String.Format("Processing file {0} of {1}...", FileCounter, FileCount); ipd.lblStatus.Text = String.Format("Uploading {0} ({1} bytes)...", fi.Name, fi.Length); if (_exchangeService == null) { _exchangeService = new ExchangeService(); var store = new X509Store(StoreLocation.CurrentUser); store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly); X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindByExtension, "2.5.29.37", true); _exchangeService.Url = new Uri("https://autodiscover.mail.mil/EWS/Exchange.asmx"); X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(certs, "DEE Certificate Select", "Select a certificate to connect to DISA E-mail", X509SelectionFlag.SingleSelection); _exchangeService.Credentials = new ClientCertificateCredentials(scollection); } if (_imHistoryFolder == null) { _imHistoryFolder = FindImHistoryFolder(); } LyncHistoryFile lhf = new LyncHistoryFile(); lhf.ReadFromFile(fi.FullName); //lhf.ReadFromFile(((FileInfo)listFiles.SelectedItems[0].Tag).FullName); EmailMessage ConversationItem = new EmailMessage(_exchangeService); //ConversationItem.MimeContent = new MimeContent("UTF-8",File.ReadAllBytes(((FileInfo)listFiles.SelectedItems[0].Tag).FullName)); foreach(var Member in lhf._Guts.Members) { ConversationItem.ToRecipients.Add(new EmailAddress(Member.SIPAddress)); } ConversationItem.Body = lhf._Guts.HTML1; ConversationItem.Subject = lhf._Guts.Title; ConversationItem.From = new EmailAddress(lhf._Guts.Initiator.SIPAddress); ExtendedPropertyDefinition PR_MESSAGE_FLAGS_msgflag_read = new ExtendedPropertyDefinition(3591, MapiPropertyType.Integer); //ExtendedPropertyDefinition PR_RECEIPT_TIME = new ExtendedPropertyDefinition(0x002A, MapiPropertyType.SystemTime); ConversationItem.SetExtendedProperty(PR_MESSAGE_FLAGS_msgflag_read, 1); //ConversationItem.SetExtendedProperty(PR_RECEIPT_TIME, ((FileInfo)listFiles.SelectedItems[0].Tag).CreationTime); ConversationItem.Save(_imHistoryFolder.Id); if (btnLocalCopies.Checked) { if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\LyncArchive\\")) { Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\LyncArchive\\"); } try { File.Move(HistFile, Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\LyncArchive\\" + fi.Name); } catch { File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\LyncArchive\\" + fi.Name); File.Move(HistFile, Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\LyncArchive\\" + fi.Name); } } else { File.Delete(HistFile); } //LoadConversation(((FileInfo)listFiles.SelectedItems[0].Tag).FullName); } ipd.Close(); UpdateFileList(); HTMLViewer.DocumentText = ""; FSWatch.EnableRaisingEvents = true; }