Этот код работает, за исключением того, что часть тела (строка cntrmsg) не подтверждает возврат каретки внутри строки.
Я получаю все по одной линии (номер телефона x'd для конфиденциальности). Вот что я получаю:
Тип проверки: ЗАКЛЮЧИТЕЛЬНАЯ СТРОИТЕЛЬНАЯ ИНСПЕКЦИЯ Результаты проверки: УТВЕРЖДАЮ или два Крэйг проведет финал по сантехнике. Никаких проблем с нашей стороны не наблюдалось.
Как-нибудь обойтись?
private void sendemail_Click(object sender, EventArgs e)
{
// see who applied for permit then see who email should be sent to if email is missing
string mailto = "";
string ownremail = "";
SqlCommand comm = GetConnectedClass.newsqlconnection("SELECT ApplCode,OwnrEmail from dbo.prmtmain WHERE PrmtTNum = @inspptno");
comm.Parameters.AddWithValue("@inspptno", inspptno.Text);
DataTable dt = new DataTable();
dt.Load(comm.ExecuteReader());
if (dt.Rows[0].Field<string>("ApplCode") == "O")
{ if (dt.Rows[0].Field<string>("OwnrEmail") != "")
{ mailto = dt.Rows[0].Field<string>("OwnrEmail"); ownremail = dt.Rows[0].Field<string>("OwnrEmail"); }
else { mailto = "Please enter an email address..."; }
}
if (dt.Rows[0].Field<string>("ApplCode") == "C")
{
// go get cntremail / if no cntr email see if owner has one else generic msg to enter addr
comm = GetConnectedClass.newsqlconnection("SELECT CntrEmail FROM dbo.cntrmast WHERE CntrName = @cntrname");
comm.Parameters.AddWithValue("@cntrname", cntrname.Text);
dt.Load(comm.ExecuteReader());
if (dt.Rows[0].Field<string>("CntrEmail") != "")
{ mailto = dt.Rows[0].Field<string>("CntrEmail"); }
else if (ownremail != "")
{ mailto = dt.Rows[0].Field<string>("OwnrEmail"); }
else { mailto = "Please enter an email address..."; }
}
if (dt.Rows[0].Field<string>("ApplCode") != "O" && dt.Rows[0].Field<string>("ApplCode") != "C")
{ mailto = "Please enter an email address..."; }
string rslt = "";
if (result.Text.Trim() == "A")
{ rslt = "APPROVED"; }
else if (result.Text.Trim() == "C")
{ rslt = "CONDITIONALLY APPROVED"; }
else if (result.Text == "V")
{ rslt = "VIOLATON"; }
else if (result.Text == "NONE")
{ rslt = "No Results Posted"; }
// construct body
string cntrmsg = @"Inspection Type: " + inspdesc.Text + "\r\nInspection Results: " + rslt +
"\r\n"+remarks.Text;
if (app.serinumb == "795")
{ cntrmsg = cntrmsg + "\r\nAll corrections must be fixed within 30 days. \r\nOccupancy may not take place until a Final Occupancy Certificate is Issued. \nSubject to fines."; }
if (app.serinumb == "849")//piperton GO GET REINSPFEE ASK????
{ cntrmsg = cntrmsg + "\r\nThis inspection has failed. A re-inspection fee of $"; }
// construct address/subject
string email = "mailto:" + mailto + "?subject=" + "Address: " + jobaddress.Text +
" Permit #: " + inspptno.Text + " Insp #: " + Convert.ToString(inspnumb.Text) +
"&body="+ cntrmsg;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = email;
proc.Start();
}