protected void Button1_Click(object sender, System.EventArgs e) { mailMessage1.BuildMessage(edtBody.Text, ""); mailMessage1.From.FullAddress = edtFrom.Text; mailMessage1.ToList.EmailAddresses = edtTo.Text; mailMessage1.Subject = edtSubject.Text; smtprelay1.DnsServer = edtDns.Text; smtprelay1.Send(mailMessage1); edtResult.Text = ""; foreach (SmtpRelayStatus statusItem in smtprelay1.StatusList) { edtResult.Text += "===== " + Server.HtmlEncode(statusItem.Domain) + " =====\r\n"; edtResult.Text += "Mail server: " + Server.HtmlEncode(statusItem.MailServer) + "\r\n"; if (statusItem.IsSent) { edtResult.Text += "Status: Sent\r\n"; } else { edtResult.Text += "Status: Not Sent\r\n"; } edtResult.Text += "Server response: " + Server.HtmlEncode(statusItem.ResponseText) + "\r\n"; edtResult.Text += "Error: " + Server.HtmlEncode(statusItem.ErrorText) + "\r\n\r\n"; } }
private void btnSend_Click(object sender, System.EventArgs e) { btnSend.Enabled = false; try { mailMessage1.BuildMessage(memText.Text, ""); mailMessage1.From.FullAddress = edtSender.Text; mailMessage1.ToList.EmailAddresses = edtRecipient.Text; mailMessage1.Subject = edtSubject.Text; smtpRelay1.DnsServer = edtDNS.Text; smtpRelay1.TimeOut = Convert.ToInt32(edtDNSTimeOut.Text) * 1000; smtpRelay1.Send(mailMessage1); ShowResults(); } finally { btnSend.Enabled = true; } }