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 Outlook(TimelineHandler handler) { try { //redemption prep //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 DirectoryInfo currentDir = new FileInfo(GetType().Assembly.Location).Directory; RedemptionLoader.DllLocation64Bit = Path.GetFullPath(currentDir + @"\lib\redemption64.dll"); RedemptionLoader.DllLocation32Bit = Path.GetFullPath(currentDir + @"\lib\redemption.dll"); //Create a Redemption object and use it _log.Trace("Creating new RDO session"); _session = RedemptionLoader.new_RDOSession(); _log.Trace("Attempting RDO session logon..."); _session.Logon(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } catch (Exception e) { _log.Error($"RDO load error: {e}"); } try { _app = new Microsoft.Office.Interop.Outlook.Application(); _oMapiNamespace = _app.GetNamespace("MAPI"); _folderInbox = _oMapiNamespace.GetDefaultFolder(OlDefaultFolders.olFolderInbox); _folderOutbox = _oMapiNamespace.GetDefaultFolder(OlDefaultFolders.olFolderOutbox); _folderSent = _oMapiNamespace.GetDefaultFolder(OlDefaultFolders.olFolderSentMail); _log.Trace("Launching Outlook"); _folderInbox.Display(); if (handler.Loop) { while (true) { ExecuteEvents(handler); } } else { ExecuteEvents(handler); } } catch (Exception e) { _log.Error(e); } }
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 OutlookRedemptionClass() { rdo = RedemptionLoader.new_RDOSession(); }
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); }