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(); }
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 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 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); }