private void convertButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(pstOutputPath.Text) || string.IsNullOrEmpty(folderInputPath.Text)) { MessageBox.Show("Please select both paths !"); return; } RDOSession session = new RDOSession(); // throws exception 1 session.LogonPstStore(pstOutputPath.Text); RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox); string[] fileEntries = Directory.GetFiles(folderInputPath.Text, "*.eml"); foreach (string filePath in fileEntries) { RDOMail mail = folder.Items.Add("IPM.Mail"); mail.Sent = true; mail.Import(filePath, 1024); // folder.Items.Add(mail); mail.Save(); } session.Logoff(); MessageBox.Show("Done converting !"); }
static void Main(string[] args) { //tell the app where the 32 and 64 bit dlls are located //by default, they are assumed to be in the same folder as the current assembly and be named //Redemption.dll and Redemption64.dll. //In that case, you do not need to set the two properties below RedemptionLoader.DllLocation64Bit = @"Redemption/redemption64.dll"; RedemptionLoader.DllLocation32Bit = @"Redemption/redemption.dll"; //Create a Redemption object and use it RDOSession session = RedemptionLoader.new_RDOSession(); session.Logon(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); var stores = session.Stores; foreach (RDOStore rdoStore in stores) { if (rdoStore.Name.Contains("michael")) { var folderId = rdoStore.RootFolder.EntryID; PerformMailFix(folderId, session); } } Console.WriteLine(count); Console.ReadKey(); session.Logoff(); }
public static void SyncPSTFiles() { if (Global.isSyncing) { Log.Append("ERROR: Cannot sync pst files because email synchronization is in progress"); return; } TimeSpan startTime = DateTime.Now.TimeOfDay; Log.Append("Syncing all available .pst files..."); string[] pstFiles = Directory.GetFiles(pstSyncDirectoryPath, "*.pst*"); foreach (string filePath in pstFiles.Where(x => !x.Contains("tmp"))) { string dumpPath = pstDumpDirectoryPath + Path.GetFileName(filePath); File.Move(filePath, dumpPath); Log.Append(String.Format(" Syncing emails from pst file '{0}'", Path.GetFileName(filePath))); RDOSession session = new RDOSession(); session.LogonPstStore(dumpPath); RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox); // Log-purpose parameters int pstEmailCount = folder.Items.Count; int currentEmailCount = 0; foreach (RDOMail mail in folder.Items) { currentEmailCount++; Email email = new Email() { ID = Global.GetAttachmentID(), UID = mail.EntryID, To = mail.To, From = mail.SenderEmailAddress, Subject = mail.Subject, MailDate = mail.SentOn }; email.RetrieveMsg(); Global.AppendEmail(email, String.Format("{0}/{1}", currentEmailCount, pstEmailCount)); mail.SaveAs(Global.messagesDirectoryPath + email.ID + ".eml", rdoSaveAsType.olRFC822); } session.Logoff(); } pstFiles.Where(x => !x.Contains("tmp")).ForEach(x => Log.Append(String.Format(" Moving pst. file \"{0}\"", x))); Log.Append(String.Format("Synced all available PST files. Process took {0}", Arithmetic.GetStopWatchStr((DateTime.Now.TimeOfDay - startTime).TotalMilliseconds))); }
private SortedList <string, Rfc822Message> getOutlookMessages() { System.Collections.Generic.SortedList <string, Rfc822Message> messages = new System.Collections.Generic.SortedList <string, Rfc822Message>(); //Dim tempApp As Outlook.Application //Dim tempInbox As Outlook.MAPIFolder //Dim InboxItems As Outlook.Items //Dim tempMail As Object = Nothing //Dim objattachments, objAttach RDOSession session = null; //object inbox = null; try { //tempApp = New Outlook.Application session = (RDOSession)Interaction.CreateObject("Redemption.RDOSession"); session.Logon(); } catch (System.Exception ex) { GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, "Unable to create Outlook object: " + ex.Message, false); return(null); } //tempInbox = tempApp.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) RDOFolder inbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox); //InboxItems = tempInbox.Items //Dim msg As Outlook.MailItem foreach (MailItem msg in inbox.Items) { //For Each msg In InboxItems if (!string.IsNullOrEmpty(UtilFunctions.findIssueTag((Rfc822Message)msg).Trim())) { if (!UtilFunctions.searchUID(msg.EntryID)) { // No. Add to list messages.Add(msg.EntryID, (Rfc822Message)msg); } } if (!runFlag | !isEnabled) { break; // TODO: might not be correct. Was : Exit For } } session.Logoff(); string cnt = messages.Count.ToString(); cnt += " Outlook messages were found"; GlobalShared.Log.Log((int)LogClass.logType.Info, cnt, false); return(messages); }
private void ConvertStore(string path) { var name = Path.GetFileName(path); var pstPath = Path.Combine(DestinationPath, name + ".pst"); if (File.Exists(pstPath) && MessageBox.Show($"File {pstPath} already exist. Rewrite?\nAttention! You're lost all of your previous data!", "Rewrite?", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.No) { File.Delete(pstPath); } _session.LogonPstStore(pstPath, 2, name); ConvertFolder(path, _session.Stores.DefaultStore.IPMRootFolder); _session.Logoff(); }
private void ConvertStore() { if (Process.GetProcessesByName("OUTLOOK").Any()) { MessageBox.Show("Outlook is running. Please close program and rerun conversion.", "Critical error", MessageBoxButton.OK, MessageBoxImage.Stop); _message = null; return; } var name = Path.GetFileName(SourcePath); var pstPath = Path.Combine(DestinationPath, name + ".pst"); { if (MessageBox.Show($"File {pstPath} already exist. Rewrite?\nAttention! You're lost all of your previous data!", "Rewrite?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { return; } File.Delete(pstPath); } _session.LogonPstStore(pstPath, 2, name); ConvertFolder(SourcePath, _session.Stores.DefaultStore.IPMRootFolder); _session.Logoff(); }
public void CreatePSTFromWindowsLiveMailFolder(string outputPstFullPath, string windowsLiveMailDirectory) { //http://www.dimastr.com/redemption/RDOMail.htm if (File.Exists(outputPstFullPath) == false && Directory.Exists(windowsLiveMailDirectory)) { session = RedemptionLoader.new_RDOSession(); session.LogonPstStore(outputPstFullPath); FolderMailItem rootFolderMap = GetFoldersFromWindowsLiveMailLocation(windowsLiveMailDirectory); if (rootFolderMap != null && rootFolderMap.Folders != null && rootFolderMap.Folders.Any()) { //add files to root folder AddFilesToFolder(rootFolderMap.Files, session.Stores.DefaultStore.IPMRootFolder); //folders in root folder foreach (FolderMailItem rootFolderMailItem in rootFolderMap.Folders) { AddMailsToFolder(rootFolderMailItem); } } session.Logoff(); } session = null; }
public static int AdjustTimeStamp(string mailbox) { string ProjectDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); RedemptionLoader.DllLocation64Bit = ProjectDir + @"\redemption64.dll"; RedemptionLoader.DllLocation32Bit = ProjectDir + @"\redemption.dll"; if (!File.Exists(RedemptionLoader.DllLocation32Bit) || !File.Exists(RedemptionLoader.DllLocation64Bit)) { Console.WriteLine("ERROR: redemption64.dll (64-bit) or redemption.dll (32-bit) is missing from EXE directory"); Console.WriteLine($"redemption64.dll should be here: {RedemptionLoader.DllLocation64Bit}"); Console.WriteLine($"redemption.dll should be here: {RedemptionLoader.DllLocation32Bit}"); Console.WriteLine("\nTerminating with exit code -1"); return(-1); } RDOSession session = RedemptionLoader.new_RDOSession(); session.Logon(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); var stores = session.Stores; // store == "mailbox" within an Outlook profile foreach (RDOStore rdoStore in stores) { Console.WriteLine($"\nChecking Mailbox {rdoStore.Name}"); if ((rdoStore.Name.ToLower().Contains(mailbox.ToLower()))) { Console.WriteLine($" Processing Mailbox {rdoStore.Name}"); TimeSpan delta = TimeSpan.Zero; // the amount of time to shift RDOFolder IPMRoot = rdoStore.IPMRootFolder; foreach (RDOFolder folder in IPMRoot.Folders) // find newest e-mail in Inbox { Debug.WriteLine($" Top Level Folder {folder.Name}"); if (folder.Name == "Inbox") { Debug.WriteLine($" Found {folder.Name} - EntryID {folder.EntryID}"); DateTime dtNewest = GetNewestDateTimeInFolder(folder.EntryID, session); delta = DateTime.Now - dtNewest; Console.WriteLine($" Newest item in {folder.Name} is {dtNewest}, delta == {delta}"); } } ConsoleColor OrigConsoleColor = Console.ForegroundColor; char keypress; do { if (delta > new TimeSpan(100, 0, 0, 0)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\aARE YOU SURE! THIS IS OVER 100 DAYS!"); Console.ForegroundColor = OrigConsoleColor; } Console.Write("\n Adjust Inbox and Sent Items "); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(Options.BackInTime ? "BACKWARD " : "FORWARD "); Console.Write($"{delta.Days}d {delta.Hours}h {delta.Minutes}m"); Console.ForegroundColor = OrigConsoleColor; Console.Write("? [Y]es/[N]o/[C]ustom] :"); keypress = char.ToLower(Console.ReadKey().KeyChar); Console.WriteLine(); switch (keypress) { case 'y': Console.WriteLine($" Processing Mailbox {rdoStore.Name}..."); foreach (RDOFolder folder in IPMRoot.Folders) // adjust dates on all items in Inbox and Sent Items (and their subfolders) { Debug.WriteLine($" Processing Folder {folder.Name}"); if (folder.Name == "Inbox" || folder.Name == "Sent Items") { Debug.WriteLine($" Found {folder.Name} - EntryID {folder.EntryID}"); PerformMailFix(folder.EntryID, session, delta); } } break; case 'c': Console.WriteLine(" 6.12:32 6 days 12 hours 32 minutes 00 seconds"); Console.WriteLine(" 6:32 8 hours 32 minutes"); Console.WriteLine(" -6.12:32 GO BACKWARD 6 days 12 hours 32 minutes 00 seconds"); Console.Write(" Enter Custom Offset [-][d].[hh]:[mm] --> "); if (TimeSpan.TryParse(Console.ReadLine(), out delta)) { if (delta < TimeSpan.Zero) // This is a cheap way to get Abs(TimeSpan) without having to access each field of the struct. { Options.BackInTime = true; delta = delta - delta - delta; } else { Options.BackInTime = false; } } break; default: break; } } while (keypress == 'c'); } } session.Logoff(); return(count); }