public bool NotifyTo(MailEntity message) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\nNotify ..."); Console.ForegroundColor = ConsoleColor.Gray; var mailTo = MailMonitor.GetMailTo(message); Console.WriteLine(); Console.WriteLine($"To: {mailTo}"); Console.WriteLine($"From: {message.From}"); Console.WriteLine($"Data: {message.DateSent}"); Console.WriteLine($"Subject: {message.Subject}"); Console.WriteLine($"Body: {message.Body}"); return(true); }
public bool CopyTo(ConfigEntity configEntity, MailEntity message, string mailActionValue) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine($"\nCopyToFolder: {mailActionValue}"); Console.ForegroundColor = ConsoleColor.Gray; string path = AppDomain.CurrentDomain.BaseDirectory + @"Files"; string subpath = mailActionValue; DirectoryInfo dirInfo = new DirectoryInfo(path); if (!dirInfo.Exists) { dirInfo.Create(); } if (string.IsNullOrEmpty(subpath)) { subpath = ""; } else { dirInfo.CreateSubdirectory(subpath); } string writePath = Path.Combine(path, subpath, configEntity.Mail + " " + message.DateSent.ToString("d") + ".txt"); StringBuilder mailResult = new StringBuilder(); mailResult.Append("To: " + MailMonitor.GetMailTo(message)); mailResult.AppendLine(); mailResult.Append("From: " + message.From); mailResult.AppendLine(); mailResult.Append("Subject: " + message.Subject); mailResult.AppendLine(); mailResult.Append("Body: " + message.Body); using (StreamWriter sw = new StreamWriter(writePath, false, Encoding.Default)) { sw.WriteLineAsync(mailResult.ToString()); } Console.WriteLine("Письмо скопировано"); return(true); }
public bool PrintTo(MailEntity message) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\nPrint ..."); Console.ForegroundColor = ConsoleColor.Gray; MailResult = new StringBuilder(); MailResult.Append("To: " + MailMonitor.GetMailTo(message)); MailResult.AppendLine(); MailResult.Append("From: " + message.From); MailResult.AppendLine(); MailResult.Append("Subject: " + message.Subject); MailResult.AppendLine(); MailResult.Append("Body: " + message.Body); PrintDocument printDoc = new PrintDocument(); printDoc.PrintPage += PrintPageHandler; printDoc.Print(); Console.WriteLine("Письмо распечатано"); return(true); }