public SystemInfoControl() { InitializeComponent(); systemInfoList = new SystemInfoList(); systemInfoList.GetAll(); systemInfoListBindingSource.DataSource = systemInfoList; }
protected void SendMail() { if (string.IsNullOrEmpty(Address) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(Host) || string.IsNullOrEmpty(Port)) { SystemInfoList systemInfo = new SystemInfoList(); systemInfo.GetAll("Contact Us Email"); systemInfo.ForEach(x => { if (x.SIKey == "Contact Us Email Address") { Address = x.SIValue; } else if (x.SIKey == "Contact Us Email Password") { Password = x.SIValue; } else if (x.SIKey == "Contact Us Email Host") { Host = x.SIValue; } else if (x.SIKey == "Contact Us Email Port") { Port = x.SIValue; } }); } // Passing the values and make a email formate to display string subject = "Chatters - Leave Us A Message"; string body = "From: " + textboxName.Text + "\n"; body += "Contact Info: " + textboxTelEmail.Text + "\n"; body += "Message: \n" + textboxMessage.Text + "\n"; // smtp settings var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = Host; smtp.Port = Convert.ToInt32(Port); smtp.EnableSsl = true; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new System.Net.NetworkCredential(Address, Password); smtp.Timeout = 20000; } // Passing values to smtp object smtp.Send(Address, Address, subject, body); }