private SendMailParameters CollectInfo() { SendMailParameters result = new SendMailParameters(); SmtpParameters sp = new SmtpParameters(); LogOnIdentity identity = new LogOnIdentity(textBoxLogOnName.Text, textBoxPassword.Text); ServerInfo serverInfo = new ServerInfo(textBoxServer.Text, identity); int port = 0; if (int.TryParse(textBoxPort.Text, out port)) { serverInfo.Port = port; } serverInfo.AuthenticateType = (AuthenticateType)Enum.Parse(typeof(AuthenticateType), (string)comboBoxAuthenticateType.SelectedValue); sp.ServerInfo = serverInfo; sp.UseDefaultCredentials = serverInfo.AuthenticateType == AuthenticateType.Anonymous; if (textBoxSignInAddress.Text.IsNotEmpty()) { sp.DefaultSender = EmailAddress.FromDescription(textBoxSignInAddress.Text); } sp.AfterSentOP = EmailMessageAfterSentOP.NotPersisted; result.SmtpParams = sp; result.DefaultEmailSubject = textBoxMessage.Text; result.ToAddress = EmailAddress.FromDescription(textBoxDest.Text); return(result); }
public void EmailAddressParsingTest() { EmailAddress address1 = EmailAddress.FromDescription("Tooling<*****@*****.**>"); Assert.AreEqual("Tooling", address1.DisplayName); Assert.AreEqual("*****@*****.**", address1.Address); Console.WriteLine(address1); EmailAddress address2 = EmailAddress.FromDescription("*****@*****.**"); Assert.AreEqual("*****@*****.**", address1.Address); Console.WriteLine(address2); }