private static void PerformMailFix(string folderId, RDOSession session, TimeSpan delta) { RDOFolder folder = session.GetFolderFromID(folderId); if ((folder.FolderKind == rdoFolderKind.fkSearch) || (delta == TimeSpan.Zero)) { return; } DateTime oldTimeStamp, newTimeStamp; foreach (RDOMail item in folder.Items) { oldTimeStamp = item.ReceivedTime; newTimeStamp = Options.BackInTime ? (oldTimeStamp - delta) : (oldTimeStamp + delta); item.ReceivedTime = newTimeStamp; if (!Options.TestMode) { item.Save(); } count++; Debug.WriteLine($" ReceivedTime is {oldTimeStamp}, set to {newTimeStamp}"); } foreach (RDOFolder subFolder in folder.Folders) { Debug.WriteLine($" Processing subfolder {subFolder.Name}"); PerformMailFix(subFolder.EntryID, session, delta); } }
private static void PerformMailFix(string folderId, RDOSession session) { var folder = session.GetFolderFromID(folderId); if (folder.FolderKind == rdoFolderKind.fkSearch) { return; } var before = new DateTime(2014, 06, 30); foreach (RDOMail item in folder.Items) { if (item.ReceivedTime >= before) { continue; } var diff = item.ReceivedTime - item.SentOn; if (!(diff.TotalHours > 10)) { continue; } Console.WriteLine("" + item.Subject + " - " + item.ReceivedTime + " " + item.SentOn); count++; item.ReceivedTime = item.SentOn; item.Save(); } Console.WriteLine(folder.DefaultMessageClass); //do the same fix for all subfolders foreach (RDOFolder subFolder in folder.Folders) { PerformMailFix(subFolder.EntryID, session); } }
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 fOutlookFolder(RDOSession session) { InitializeComponent(); mySession = session; LoadStores(); LoadFolders(treeView1.Nodes.Find(mySession.Stores.DefaultStore.EntryID, true)[0], mySession.Stores.DefaultStore.IPMRootFolder); // treeView1.SelectedNode = treeView1.Nodes.Find(mySession.Stores.DefaultStore.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).EntryID, true)[0]; }
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))); }
public static void ExtractPst(string pstFilePath, string folderPath) { if (pstFilePath == null) { throw new ArgumentNullException("pstFilePath"); } RDOSession session = new RDOSession(); RDOPstStore store = session.LogonPstStore(pstFilePath); ExtractPstFolder(store.RootFolder, folderPath); }
public static bool MoveMail(string entryId, string newFolderName) { var application = new Application(); application.Session.Logon(); if (application.Session == null) { return(false); } MAPIFolder destFldr = null; foreach (MAPIFolder folder in application.Session.Folders) { destFldr = GetFolder(folder, newFolderName); if (destFldr != null) { break; } } if (destFldr == null) { return(false); } try { var rdo = new RDOSession(); rdo.MAPIOBJECT = application.Session.MAPIOBJECT; var rdoMail = rdo.GetMessageFromID(entryId); if (rdoMail == null) { return(false); } var rodFolder = rdo.GetFolderFromID(destFldr.EntryID); rdoMail.Move(rodFolder); return(true); } catch { return(false); } }
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); }
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 static DateTime GetNewestDateTimeInFolder(string folderID, RDOSession session) { DateTime dt = DateTime.MinValue; RDOFolder folder = session.GetFolderFromID(folderID); foreach (RDOMail item in folder.Items) { if (item.ReceivedTime > dt) { dt = item.ReceivedTime; } } return(dt); }
static void Main(string[] args) { string path = Path.GetFullPath(@"..\..\..\snapshot.pst"); // Load the PST RDOSession session = new RDOSession(); session.LogonPstStore(path); // Grab everything in the inbox RDOItems inbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).Items; // Filter out all emails from the flag mailer RDOItems spoofed = inbox.Restrict("[SenderEmailAddress]='*****@*****.**'"); // The flag is hidden in the send date (year), // sorted by the delivery date string flag = string.Concat(spoofed.OfType<RDOMail>() .OrderBy(m => m.ReceivedTime) // Sort by delivery date .Select(m => m.SentOn.Year - 2000) // Get the flag ordinal values .Select(c => (char) c)); // Convert to char Console.Out.WriteLine(flag); }
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; }
static void Main(string[] args) { string path = Path.GetFullPath(@"..\..\..\snapshot.pst"); // Load the PST RDOSession session = new RDOSession(); session.LogonPstStore(path); // Grab everything in the inbox RDOItems inbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).Items; // Filter out all emails from the flag mailer RDOItems spoofed = inbox.Restrict("[SenderEmailAddress]='*****@*****.**'"); // The flag is hidden in the send date (year), // sorted by the delivery date string flag = string.Concat(spoofed.OfType <RDOMail>() .OrderBy(m => m.ReceivedTime) // Sort by delivery date .Select(m => m.SentOn.Year - 2000) // Get the flag ordinal values .Select(c => (char)c)); // Convert to char Console.Out.WriteLine(flag); }
public void Load() { //check that the path exists var redemptionFilePath = RedemptionLoader.DllLocation32Bit; //MessageBox.Show("Load path = " + redemptionFilePath.ToString()); if (!File.Exists(redemptionFilePath)) { var currentPath = Assembly.GetExecutingAssembly().Location; currentPath = Path.GetDirectoryName(currentPath); if (currentPath != null) { RedemptionLoader.DllLocation64Bit = Path.Combine(currentPath, "redemption64.dll"); RedemptionLoader.DllLocation32Bit = Path.Combine(currentPath, "redemption.dll"); } } //MessageBox.Show("Redemption loaded"); RdoSession = RedemptionLoader.new_RDOSession(); //MessageBox.Show("Start Session logon"); SessionLogon(); //MessageBox.Show("Start Session logon done"); }
public void Init() { if (!initilized) { Log.Info("begin initialising cache..."); this.rdoSession = new RDOSession(); rdoSession.Logon(); BookitDB db = new BookitDB(); this.emails = db.MeetingRooms.Select(mr => mr.Email).ToList(); poolingThread = new Thread(PullingWorker); poolingThread.IsBackground = true; poolingThread.Start(); initilized = true; Log.Info("cache initialized"); } }
public OutlookPstManager(Redemption.RDOSession session, Redemption.RDOFolder baseFolder) { this._session = session; this._baseFolder = baseFolder; }
static void Main(string[] args) { // <3 visual studio string origpath = Path.GetFullPath(@"..\..\..\backup.pst"); // Just full of spam string targetpath = Path.GetFullPath(@"..\..\..\..\snapshot.pst"); // This will be the challenge // Copy over the original pst File.Copy(origpath, targetpath, true); // Have to use Redemption for this, since outlook is "secure" // Open the PST RDOSession session = new RDOSession(); session.LogonPstStore(targetpath); // Load the target inbox RDOFolder inboxFolder = session.GetFolderFromPath("PRIVATE INBOX"); RDOItems inbox = inboxFolder.Items; inbox.Sort("ReceivedTime", false); // Pre-sort them in ascending order Console.WriteLine(inbox.Count); // Encode the flag in DateTimes, hiding it in the year (2000 + c) // e.g. 3/9/2102 12:45:54 AM ==> 102 => 'f' var flag = "flag{w1k1L3ak5_g0T_n0tH1ng_0n_m3}".Select(c => EncodeChar(c)).ToList(); // fun var aliases = Cycle(aliasStrings).GetEnumerator(); var subjects = Cycle(subjectStrings).GetEnumerator(); // Approximately space out the emails int range = inbox.Count / flag.Count; for (int i = 0; i < flag.Count; i++) { // Copy the delivery time from a random email in this range DateTime recvTime = inbox[rand.Next(i * range, (i + 1) * range)].ReceivedTime; DateTime flagtime = flag[i]; Console.WriteLine($"{flagtime} => {recvTime}"); // Create a fake email with the two times and other fun stuff RDOMail flagmail = inbox.Add("IPM.Note"); flagmail.Importance = 1; flagmail.ReceivedTime = recvTime; flagmail.SentOn = flagtime; flagmail.Subject = subjects.Next(); flagmail.To = "*****@*****.**"; flagmail.Sender = session.GetAddressEntryFromID(session.AddressBook.CreateOneOffEntryID(aliases.Next(), "SMTP", "*****@*****.**", false, false)); flagmail.Save(); } // Sort the emails by delivery time, scattering the spoofed ones (in order) across the dump inbox = inboxFolder.Items; Console.WriteLine(inbox.Count); inbox.Sort("ReceivedTime", false); // Guess we're doing it this way -__- Console.WriteLine("Flag is in place, moving to inbox..."); RDOFolder targetInbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox); foreach (RDOMail email in inbox) { email.CopyTo(targetInbox); } targetInbox.Save(); Console.WriteLine("Done!"); }
public PstReadingService(string filePath) { _session = new RDOSession(); _session.LogonPstStore(filePath); _IPMRoot = _session.Stores.DefaultStore.IPMRootFolder.Folders; }
static void Main(string[] args) { RDOSession session = new RDOSession(); RDOPstStore store = session.LogonPstStore(@"c:\backup.pst"); //RDOPstStore store = session.Stores.AddPSTStore(@"c:\backup.pst"); }
public ActionResult Messages() { RDOSession Session = new RDOSession(); Session.Logon(); RDOExchangeMailboxStore mbStore = (RDOExchangeMailboxStore)Session.Stores.DefaultStore; //Evaluate with Drafts folder: RDOFolder Inbox = (RDOFolder)Session.GetDefaultFolder(rdoDefaultFolders.olFolderDrafts); var listing = new List<Message>(); foreach (RDOMail item in Inbox.Items) { var temp = new Message(); temp.Subject = item.Subject; temp.Received = item.ReceivedTime; temp.ID = item.EntryID; listing.Add(temp); temp = null; } GC.Collect(); return View(listing.ToList<Message>()); }
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); }