protected MailWriteReference(string id, string sender, IEnumerable <string> recipients, IMailStore store) { Id = id; Sender = sender; Store = store; Recipients = ImmutableList.CreateRange(recipients); }
/// <summary> /// Constructor /// </summary> /// <param name="seq">Sequence file content </param> public ExecuteSequence(MailSimSequence seq) { typeFuncs[typeof(MailSimOperationsMailSend)] = (oper) => MailSend((MailSimOperationsMailSend)oper); typeFuncs[typeof(MailSimOperationsMailDelete)] = (oper) => MailDelete((MailSimOperationsMailDelete)oper); typeFuncs[typeof(MailSimOperationsMailReply)] = (oper) => MailReply((MailSimOperationsMailReply)oper); typeFuncs[typeof(MailSimOperationsMailForward)] = (oper) => MailForward((MailSimOperationsMailForward)oper); typeFuncs[typeof(MailSimOperationsMailMove)] = (oper) => MailMove((MailSimOperationsMailMove)oper); typeFuncs[typeof(MailSimOperationsFolderCreate)] = (oper) => FolderCreate((MailSimOperationsFolderCreate)oper); typeFuncs[typeof(MailSimOperationsFolderDelete)] = (oper) => FolderDelete((MailSimOperationsFolderDelete)oper); typeFuncs[typeof(MailSimOperationsEventMonitor)] = (oper) => EventMonitor((MailSimOperationsEventMonitor)oper); sequence = seq; if (sequence != null) { try { olMailStore = ProviderFactory.CreateMailStore(null, sequence); } catch (Exception) { Log.Out(Log.Severity.Error, "Run", "Error encountered during initialization"); throw; } } }
/// <summary> /// Constructor /// </summary> /// <param name="seq">Sequence file content </param> internal ExecuteSequence(MailSimSequence seq, MailSimOptions options) { typeFuncs[typeof(MailSimOperationsMailSend)] = (oper) => MailSend((MailSimOperationsMailSend)oper); typeFuncs[typeof(MailSimOperationsMailDelete)] = (oper) => MailDelete((MailSimOperationsMailDelete)oper); typeFuncs[typeof(MailSimOperationsMailReply)] = (oper) => MailReply((MailSimOperationsMailReply)oper); typeFuncs[typeof(MailSimOperationsMailForward)] = (oper) => MailForward((MailSimOperationsMailForward)oper); typeFuncs[typeof(MailSimOperationsMailMove)] = (oper) => MailMove((MailSimOperationsMailMove)oper); typeFuncs[typeof(MailSimOperationsFolderCreate)] = (oper) => FolderCreate((MailSimOperationsFolderCreate)oper); typeFuncs[typeof(MailSimOperationsFolderDelete)] = (oper) => FolderDelete((MailSimOperationsFolderDelete)oper); typeFuncs[typeof(MailSimOperationsEventMonitor)] = (oper) => EventMonitor((MailSimOperationsEventMonitor)oper); sequence = seq; if (sequence != null) { try { olMailStore = ProviderFactory.CreateMailStore(null, options); } catch (Exception) { Log.Out(Log.Severity.Error, "Run", "Error encountered during initialization"); throw; } } }
public MockMailReference( string id, string sender, IImmutableList <string> recipients, bool saved, string body, IMailStore store) : this(id, sender, recipients, saved, Encoding.ASCII.GetBytes(body), store) { }
public WriteReference( string id, string tempPath, string path, string sender, IEnumerable <string> recipients, Stream bodyStream, IMailStore store) : base(id, sender, recipients, store) { BodyStream = bodyStream; TempPath = tempPath; Path = path; }
public MailService() { var mail_host = ConfigurationManager.AppSettings["mail_host"]; var mail_port = int.Parse(ConfigurationManager.AppSettings["mail_port"]); var mail_usessl = bool.Parse(ConfigurationManager.AppSettings["mail_usessl"]); var mail_user = ConfigurationManager.AppSettings["mail_user"]; var mail_password = ConfigurationManager.AppSettings["mail_password"]; _clientImap = new ImapClient(new ProtocolLogger("maillog.txt")); _clientImap.ServerCertificateValidationCallback = (s, c, h, e) => true; _clientImap.Connect(mail_host, mail_port, mail_usessl); _clientImap.AuthenticationMechanisms.Remove("XOAUTH2"); _clientImap.Authenticate(mail_user, mail_password); }
public ReadReference( string id, string sender, IEnumerable <string> recipients, string path, Stream bodyStream, IMailStore store) { Id = id; BodyStream = bodyStream; Store = store; Path = path; Sender = sender; Recipients = ImmutableList.CreateRange(recipients); }
public MockMailReference( string id, string sender, IImmutableList <string> recipients, bool saved, byte[] body, IMailStore store) { Id = id; Sender = sender; Recipients = recipients; BackupBodyStream = body == null ? new MemoryStream() : new MemoryStream(body); BodyStream = new MultiStream(new Stream[] { BackupBodyStream }, true); IsSaved = saved; Store = store; }
public SmtpSession( SecurableConnection connection, SmtpImplementationFactory implementationFactory, SmtpSettings settings, string ipAddress, string connectedIpAddress, IMailStore mailStore, IUserStore userStore) { Connection = connection; ImplementationFactory = implementationFactory; Settings = settings; IpAddress = ipAddress; ConnectedIpAddress = connectedIpAddress; MailStore = mailStore; UserStore = userStore; }
} // How many messages the handler has deleted since startup. public O2Handler() { Username = Util.ForceGetEnv("O2_USERNAME"); Password = Util.ForceGetEnv("O2_PASSWORD"); try { var period = Util.ForceGetEnv("WAIT_PERIOD"); WaitPeriod = int.Parse(period); if (WaitPeriod <= 0) { Console.WriteLine("The WAIT_PERIOD environment variable must be a positive 32-bit signed integer."); Environment.Exit(1); } } catch (Exception) { Console.WriteLine("The WAIT_PERIOD environment variable must be a positive 32-bit signed integer."); Environment.Exit(1); } Client = new ImapClient(); Epoch = DateTime.UtcNow; }
/// <summary> /// Constructor /// </summary> /// <param name="seq">Sequence file content </param> public ExecuteSequence(MailSimSequence seq) { typeFuncs[typeof(MailSimOperationsMailSend)] = (oper) => MailSend((MailSimOperationsMailSend)oper); typeFuncs[typeof(MailSimOperationsMailDelete)] = (oper) => MailDelete((MailSimOperationsMailDelete)oper); typeFuncs[typeof(MailSimOperationsMailReply)] = (oper) => MailReply((MailSimOperationsMailReply)oper); typeFuncs[typeof(MailSimOperationsMailForward)] = (oper) => MailForward((MailSimOperationsMailForward)oper); typeFuncs[typeof(MailSimOperationsMailMove)] = (oper) => MailMove((MailSimOperationsMailMove)oper); typeFuncs[typeof(MailSimOperationsFolderCreate)] = (oper) => FolderCreate((MailSimOperationsFolderCreate)oper); typeFuncs[typeof(MailSimOperationsFolderDelete)] = (oper) => FolderDelete((MailSimOperationsFolderDelete)oper); typeFuncs[typeof(MailSimOperationsEventMonitor)] = (oper) => EventMonitor((MailSimOperationsEventMonitor)oper); if (seq != null) { try { sequence = seq; // Disables the Outlook security prompt if specified if (sequence.DisableOutlookPrompt == true) { ConfigOutlookPrompts(false); } // Openes connection to Outlook with default profile, starts Outlook if it is not running // Note: Currently only the default MailStore is supported. olMailStore = ProviderFactory.CreateMailStore(null); // Initializes a random number randomNum = new Random(); } catch (Exception) { Log.Out(Log.Severity.Error, "Run", "Error encountered during initialization"); throw; } } }
/// <summary> /// Test module, focusing on Outlook (OOM) wrapper classes (Mail*) /// Also serves as an example for Mail* classes usage /// </summary> /// <param name="args">Command line argument. It is expected that the first argument is always "/t"</param> public void Execute(string[] args) { IMailStore mailStore = null; try { // We will use mailbox with display name specified in arg[1]; // otherwise, we will get the default store mailStore = ProviderFactory.CreateMailStore(args.Length > 1 ? args[1] : null); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); return; } catch (Exception ex) { Console.WriteLine(ex); return; } string mailboxName = mailStore.DisplayName; // Display all top folders in the mailbox IMailFolder rootFolder = mailStore.RootFolder; var rootFolders = rootFolder.SubFolders; foreach (var mailFolder in rootFolders) { Console.WriteLine(mailFolder.FolderPath); } // Open Inbox and loop through it's top folders IMailFolder inbox = mailStore.GetDefaultFolder("olFolderInbox"); // Registering callback for Inbox "ItemAdd" event inbox.RegisterItemAddEventHandler(FolderEvent); Console.WriteLine("Inbox has {0} mail items", inbox.MailItemsCount); var inboxSubFolders = inbox.SubFolders; IMailFolder testFolder = null; const string testFolderName = "MailSim Test Folder"; Console.WriteLine("Exploring Inbox Folders"); foreach (IMailFolder mailFolder in inboxSubFolders) { if (testFolderName == mailFolder.Name) { testFolder = mailFolder; } Console.WriteLine(mailFolder.FolderPath); } if (null == testFolder) { testFolder = inbox.AddSubFolder(testFolderName); } // Adding folder under Test Folder string folderName = "Test Subfolder " + (testFolder.SubFoldersCount + 1).ToString() + " - " + DateTime.Now.TimeOfDay.ToString(); testFolder.AddSubFolder(folderName); // Deleting folder under Test Folder if (testFolder.SubFoldersCount > 2) { testFolder.SubFolders.First().Delete(); } // Deleting email in inbox if (inbox.MailItemsCount > 2) { var mailToDelete = inbox.MailItems.First(); Console.WriteLine("Deleting email {0}", mailToDelete.Subject); mailToDelete.Delete(); } // Moving email if (inbox.MailItemsCount > 2) { inbox.MailItems.First().Move(testFolder); } // Sending new email with message attachment to matching users Console.WriteLine("Sending new email to matching GAL users"); IMailItem newMail = mailStore.NewMailItem(); newMail.Subject = "Test Mail from MailSim to GAL users " + (inbox.MailItemsCount + 1).ToString() + " - " + DateTime.Now.TimeOfDay.ToString(); newMail.Body = "Test from MailSim to matching users"; if (inbox.MailItemsCount > 0) { var message = inbox.MailItems.First(); newMail.AddAttachment(message); } newMail.AddRecipient(mailboxName); var gal = mailStore.GetGlobalAddressList(); if (gal != null) { var users = gal.GetUsers("Mailsim"); foreach (string userAddress in users) { newMail.AddRecipient(userAddress); } } if (newMail.ValidateRecipients()) { newMail.Send(); Console.WriteLine("Mail to specified users sent!"); } else { Console.WriteLine("Incorrect recipient(s), mail not sent"); } // Sending new email with to DL members Console.WriteLine("Sending new email to DL users"); newMail = mailStore.NewMailItem(); newMail.Subject = "Test Mail from MailSim to DL members " + (inbox.MailItemsCount + 1).ToString() + " - " + DateTime.Now.TimeOfDay.ToString(); newMail.Body = "Test from MailSim to DL members"; newMail.AddRecipient(mailboxName); if (gal != null) { var members = gal.GetDLMembers("Mailsim Users"); if (members.Any() == false) { Console.WriteLine("ERROR: Distribution list not found or empty"); } else { foreach (string userAddress in members) { newMail.AddRecipient(userAddress); } } } if (newMail.ValidateRecipients()) { newMail.Send(); Console.WriteLine("Mail to distribution list members sent!"); } else { Console.WriteLine("Incorrect recipient(s), mail not sent"); } var inboxMailItems = inbox.MailItems; // Reply All if (inbox.MailItemsCount >= 1) { var replyMail = inboxMailItems.First().Reply(true); replyMail.Body = "Reply All by MailSim" + replyMail.Body; Console.WriteLine("Message Body:"); Console.WriteLine(replyMail.Body); replyMail.Send(); Console.WriteLine("Reply All mail sent!"); } // Forward if (inbox.MailItemsCount >= 2) { var forwardMail = inboxMailItems.Skip(1).First().Forward(); forwardMail.Body = "Forward by MailSim" + forwardMail.Body; Console.WriteLine("Message Body:"); Console.WriteLine(forwardMail.Body); forwardMail.AddRecipient(mailboxName); if (forwardMail.ValidateRecipients()) { forwardMail.Send(); Console.WriteLine("Forwarded the mail(s)"); } else { Console.WriteLine("Incorrect recipient(s), mail(s) cannot be forwarded"); } } Console.WriteLine("Press any key to exit"); Console.Read(); inbox.UnRegisterItemAddEventHandler(); }
public StoredQueueMailSender(QueueSenderConfiguration configuration, IMailSender realSender, IMailStore store) : base(configuration, realSender) { this.store = store; }
public MockMailReference(string id, string sender, IImmutableList <string> recipients, bool saved, IMailStore store) : this(id, sender, recipients, saved, (byte[])null, store) { }
internal MailService(IMailStore clientImap) { _clientImap = clientImap; }