/// <summary> /// Constructor for email info object /// </summary> /// <param name="args">string[4] containing name, password, server and port</param> public EmailInfo(string[] args) { userName = args[0]; password = args[1]; serverName = args[2]; port = int.Parse(args[3]); errorSearchTerm = SearchQuery.FromContains("NewDesktop Retrospect NAS drives"); successfulSearchTerm = QueryManipulation.GetSearchQuery("success.txt", true); }
static void Main(string[] args) { // Load command line and text file info about connection + keywords EmailInfo settings = new EmailInfo(args); // Pull emails and email indicides for all unread emails IList <UniqueId> newEmailIds; IMailFolder emails = settings.GetNewEmails(out newEmailIds); // Exit program if no new emails were found if (newEmailIds.Count == 0) { Console.WriteLine("No new emails!"); return; } // Extract Retrospect non-error messages and update indices IList <UniqueId> successfulEmailIds = settings.GetSuccessful(emails, newEmailIds); // Get Ids of everything that is not an successful retrospect email IList <UniqueId> errorOrUniqueIds = newEmailIds.Except(successfulEmailIds).ToList <UniqueId>(); // Get Ids of every retrospect error message IList <UniqueId> errorIds = settings.GetFailure(emails, errorOrUniqueIds); // Get Ids of everything that is not a retrospect email IList <UniqueId> uniqueIds = errorOrUniqueIds.Except(errorIds).ToList <UniqueId>(); // Notify admin of all unique and error emails, using supplied outgoing server info EmailSender sender = new EmailSender(args); sender.SendEmails(QueryManipulation.ExtractMessages(emails, errorIds), QueryManipulation.ExtractMessages(emails, uniqueIds), successfulEmailIds.Count); // Close inbox emails.Close(); }