public void SendNullMessage() { Dictionary<string, string> options = new Dictionary<string, string>(); options["smtp-host"] = "smtp.acao.net.br"; options["smtp-port"] = "25"; SmtpMessenger messenger = new SmtpMessenger("somename", options); ResponseMessage response = messenger.Send(null); }
public void SendNoEmailMessage() { Dictionary<string, string> options = new Dictionary<string, string>(); options["smtp-host"] = "smtp.acao.net.br"; options["smtp-port"] = "25"; SmtpMessenger messenger = new SmtpMessenger("somename", options); ResponseMessage response = ((IMessenger)messenger).Send(new ResponseMessage("somemessage", ResponseMessageType.ErrorMessage)); }
public void CtorStringOptions() { Dictionary<string, string> options = new Dictionary<string, string>(); options["smtp-host"] = "smtp.nohros.com"; options["smtp-port"] = "25"; SmtpMessenger messenger = new SmtpMessenger("somename", options); Assert.Pass(); }
public void SendText() { EmailMessage message = new EmailMessage("somemessage"); message.Sender = new EmailAgent("*****@*****.**", "somename"); message.Subject = "somesubject"; message.IsBodyHtml = false; message.Message = "sometext"; message.AddRecipient(new EmailAgent("*****@*****.**", "Neylor Ohmaly")); Dictionary<string, string> options = new Dictionary<string, string>(); options["smtp-host"] = "smtp.acao.net.br"; options["smtp-port"] = "25"; SmtpMessenger messenger = new SmtpMessenger("somename", options); ResponseMessage response = messenger.Send(message); Assert.AreEqual(ResponseMessageType.ProcessedMessage, response.Type); }
/// <summary> /// Creates an instance of the <see cref="SmtpMessenger"/> class by using /// the messenger's name and options. /// </summary> /// <param name="name">A string taht identifies the SMTP messenger.</param> /// <param name="options"> A dictionary containing the configured /// messenger's options.</param> /// <exception cref="ArugmentNullException"><paramref name="name"/> or /// <paramref name="options"/> are null references.</exception> /// <exception cref="ArgumentException">A required option could not be /// found into the <paramref name="options"/> dictionary.</exception> /// <returns>A instance of the <see cref="SmtpMessenger"/> class.</returns> /// <remarks>The options recognized by this messenger are: /// <list type="bullet"> /// <item> /// <term>smtp-host</term> /// <description>The address to the SMTP server.</description> /// </item> /// <item> /// <term>smtp-port</term> /// <description>The port used to connects to the SMTP server.</description> /// </item> /// <item> /// <term>enable-ssl</term> /// <description>A boolean value that indicates if the server requires a /// SSL connection.</description> /// </item> /// </list> /// <para> /// The "smtp-host" and "smtp-port" options are required and the others /// are optional. /// </para> /// </remarks> public SmtpMessenger CreateSmtpMessenger(string name, IDictionary<string, string> options) { string host = Messenger.GetRequiredOption(kSMTPHostAddress, options); string port_str = Messenger.GetRequiredOption(kSMTPPort, options); int port; if (!int.TryParse(port_str, out port)) { throw new ArgumentException( string.Format(Resources.Messaging_SMTP_InvalidPort, port_str)); } SmtpClient smtp_client = new SmtpClient(host, port); smtp_client.EnableSsl = options.ContainsKey(kEnableSSL); SmtpMessenger messenger = new SmtpMessenger(name, smtp_client); return messenger; }
/// <summary> /// Creates an instance of the <see cref="SmtpMessenger"/> class by using /// the messenger's name and options. /// </summary> /// <param name="name">A string taht identifies the SMTP messenger.</param> /// <param name="options"> A dictionary containing the configured /// messenger's options.</param> /// <exception cref="ArugmentNullException"><paramref name="name"/> or /// <paramref name="options"/> are null references.</exception> /// <exception cref="ArgumentException">A required option could not be /// found into the <paramref name="options"/> dictionary.</exception> /// <returns>A instance of the <see cref="SmtpMessenger"/> class.</returns> /// <remarks>The options recognized by this messenger are: /// <list type="bullet"> /// <item> /// <term>smtp-host</term> /// <description>The address to the SMTP server.</description> /// </item> /// <item> /// <term>smtp-port</term> /// <description>The port used to connects to the SMTP server.</description> /// </item> /// <item> /// <term>enable-ssl</term> /// <description>A boolean value that indicates if the server requires a /// SSL connection.</description> /// </item> /// </list> /// <para> /// The "smtp-host" and "smtp-port" options are required and the others /// are optional. /// </para> /// </remarks> public SmtpMessenger CreateSmtpMessenger(string name, IDictionary <string, string> options) { string host = Messenger.GetRequiredOption(kSMTPHostAddress, options); string port_str = Messenger.GetRequiredOption(kSMTPPort, options); int port; if (!int.TryParse(port_str, out port)) { throw new ArgumentException( string.Format(Resources.Messaging_SMTP_InvalidPort, port_str)); } SmtpClient smtp_client = new SmtpClient(host, port); smtp_client.EnableSsl = options.ContainsKey(kEnableSSL); SmtpMessenger messenger = new SmtpMessenger(name, smtp_client); return(messenger); }
public void CtorStringOptionMissingRequired() { Dictionary<string, string> options = new Dictionary<string,string>(); options["someoption"] = "someoptionvalue"; SmtpMessenger messenger = new SmtpMessenger("somename", options); }
public void CtorStringNull() { SmtpMessenger messenger = new SmtpMessenger("somename", null); Assert.Pass(); }
public void CtorNullOptions() { Dictionary<string, string> options = new Dictionary<string,string>(); options["someoption"] = "someoptionvalue"; SmtpMessenger messenger = new SmtpMessenger(null, null); }
static void SendHtml() { EmailMessage message = new EmailMessage("somemessage"); message.Sender = new EmailAgent("*****@*****.**", "Comunicacao Acao"); message.Subject = "Pesquisa Perfil"; message.IsBodyHtml = true; message.Message = @"<html> <head> <title>Pesquisa Perfil Acao</title> </head> <body> <a href=""$link$""> <img alt=""Pesquisa Perfil Acao"" src=""http://192.168.203.8:8080/images/pesquisa_adm.jpg""/> </a> </body> </html>"; message.AddRecipient(new EmailAgent("*****@*****.**", "Comunicacao")); Dictionary<string, string> options = new Dictionary<string, string>(); options["smtp-host"] = "smtp.acao.net.br"; options["smtp-port"] = "25"; SmtpMessenger messenger = new SmtpMessenger("somename", options); ResponseMessage response = messenger.Send(message); }