Tom Knowlton
asked on
SMTP does not send, does not error-out, seems to do nothing!
I am running the following code. I have a breakpoint set so I know the code is being run. After the code runs, I get NO email in my inbox. Nor does an exception get raised. The code runs and nothing seems to happen, period.
::: LOST :::::
Is there a way to find-out if the SMTP server is responding at all, or where the failure point is? Normally if the SMTP server were down or something, I would expect an exception to get raised by the code, right?
::: LOST :::::
Is there a way to find-out if the SMTP server is responding at all, or where the failure point is? Normally if the SMTP server were down or something, I would expect an exception to get raised by the code, right?
protected void btnSubmit_Click(object sender, EventArgs e)
{
string body = "";
body = "Name: " + tbName.Text + "<br>";
body += "Phone: " + tbPhone.Text + "<br>";
body += "Email: " + tbEmail.Text + "<br>";
body += "Subject: " + ddlSubject.SelectedValue.ToString() + "<br>";
body += "Body: <br>" + tbBody.Text + "<br>";
//try
//{
// IWEB.eMail.SendMail("TCSMail@total-computing.com","TCSMail@total-computing.com", "TotaLink Information Request", body, tbName.Text, true);
// if (cbSendCopy.Checked)
// IWEB.eMail.SendMail("TCSMail@total-computing.com", tbEmail.Text, "TotaLink Information Request", body, "TCS Support", true);
// panelEmail.Visible = false;
// lblInfo.Text = "Thanks! We will get back to you soon.";
// hlReturnHome.Visible = true;
//}
//catch
//{
// lblInfo.Text = "There was a problem, please try again later";
//}
string host = System.Configuration.ConfigurationManager.AppSettings["SMTP_SERVER"] as string;
string erremailaddy = System.Configuration.ConfigurationManager.AppSettings["ERROREMAIL"] as string;
string smtpusername = System.Configuration.ConfigurationManager.AppSettings["SMTP_USERNAME"] as string;
string smtppassword = System.Configuration.ConfigurationManager.AppSettings["SMTP_PASSWORD"] as string;
string storename = System.Configuration.ConfigurationManager.AppSettings["StoreName"] as string;
string dbtype = System.Configuration.ConfigurationManager.AppSettings["DBTYPE"] as string;
System.Net.Mail.SmtpClient smpt = new System.Net.Mail.SmtpClient();
smpt.UseDefaultCredentials = false;
smpt.Credentials = new System.Net.NetworkCredential(smtpusername, smtppassword);
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.Body = "<b><h1>" + body + "</h1></b><br><br>" + body;
smpt.Host = host;
msg.IsBodyHtml = true;
msg.From = new System.Net.Mail.MailAddress("TCSMail@total-computing.com", "IWEB ERROR");
msg.Subject = "IWEB ERROR AT " + storename;
msg.To.Add(erremailaddy);
smpt.Send(msg);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What is MailMessage?
This is not recoginized. What DLL do I reference?
This is not recoginized. What DLL do I reference?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thx
ASKER
In the meantime I tried the following from the command line on the webserver:
Open in new window