|
|
@ -45,9 +45,9 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI |
|
|
|
#region Custome eventBind
|
|
|
|
|
|
|
|
string filePath = " C:\\U8NetPrintResult\\Guest"; |
|
|
|
string filePathD = " D:\\U8NetPrintResult\\Guest"; |
|
|
|
|
|
|
|
string filePathD = " E:\\U8NetPrintResult\\Guest"; |
|
|
|
|
|
|
|
string PurMail = ""; |
|
|
|
|
|
|
|
//DropDownList_Notices_TextChanged...
|
|
|
|
private void DropDownList_Notices_TextChanged_Extend(object sender, EventArgs e) |
|
|
@ -215,13 +215,14 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI |
|
|
|
SmtpClient client = new SmtpClient(); |
|
|
|
|
|
|
|
client.Host = SendHost;//SMTP服务器地址
|
|
|
|
//client.EnableSsl = true;
|
|
|
|
client.EnableSsl = true; |
|
|
|
client.UseDefaultCredentials = false; |
|
|
|
|
|
|
|
//发件人邮箱账号
|
|
|
|
client.Credentials = new System.Net.NetworkCredential(SendAddress, SendPassword); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MailAddress from = new MailAddress(SendAddress, SendPassword); //邮件的发件人
|
|
|
|
MailMessage message = new MailMessage(); |
|
|
|
try |
|
|
@ -238,14 +239,43 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI |
|
|
|
message.CC.Add(CCAddress);//抄送人邮箱
|
|
|
|
} |
|
|
|
|
|
|
|
string SelSQL = @"SELECT top 1 PrintTemplateText FROM Cust_PrintTemplateText "; |
|
|
|
DataSet SelSQLDs = new DataSet(); |
|
|
|
UFSoft.UBF.Util.DataAccess.DataAccessor.RunSQL(UFSoft.UBF.Util.DataAccess.DataAccessor.GetConn(), SelSQL.ToString(), null, out SelSQLDs); |
|
|
|
DataTable dt = new DataTable(); |
|
|
|
dt = SelSQLDs.Tables[0]; |
|
|
|
if (dt.Rows.Count < 1) |
|
|
|
{ |
|
|
|
throw new Exception("配置表Cust_PrintTemplateText中不存在对应信息,请先维护"); |
|
|
|
} |
|
|
|
|
|
|
|
message.From = new MailAddress(SendAddress);//发件人邮箱
|
|
|
|
message.Subject = this.MailTitle86.Text;//邮件标题
|
|
|
|
message.SubjectEncoding = Encoding.UTF8;//标题格式为UTF8
|
|
|
|
|
|
|
|
string _Body = this.MailText53.Text; |
|
|
|
string _Body = dt.Rows[0][0].ToString(); |
|
|
|
string[] strArray = _Body.Split(new char[1] { ' ' }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string _SelSQL = @"select c.DefaultEmail from PM_PurchaseOrder a
|
|
|
|
left join CBO_Operators b on a.PurOper = b.ID |
|
|
|
left join Base_Contact c on b.Contact = c.ID |
|
|
|
where a.DocNo ='" + CurrentState["POCode"].ToString() + "' and a.Org='" + CurrentState["OrgID"].ToString() + "'";
|
|
|
|
DataSet _SelSQLDs = new DataSet(); |
|
|
|
UFSoft.UBF.Util.DataAccess.DataAccessor.RunSQL(UFSoft.UBF.Util.DataAccess.DataAccessor.GetConn(), _SelSQL.ToString(), null, out _SelSQLDs); |
|
|
|
DataTable dtPur = new DataTable(); |
|
|
|
dtPur = _SelSQLDs.Tables[0]; |
|
|
|
if (dtPur.Rows.Count == 0) |
|
|
|
{ |
|
|
|
throw new Exception("采购员未维护邮箱"); |
|
|
|
} |
|
|
|
|
|
|
|
string PurMail = dtPur.Rows[0]["DefaultEmail"].ToString();//采购员收件邮箱
|
|
|
|
|
|
|
|
|
|
|
|
string mailMessage = @"<html>
|
|
|
|
<body> |
|
|
|
<table style='width: 100%; table-layout: fixed; font-size: 16px;' border: 0px cellspacing='4' > |
|
|
@ -274,7 +304,17 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI |
|
|
|
} |
|
|
|
i++; |
|
|
|
} |
|
|
|
mailMessage += string.Format(@"
|
|
|
|
<tr> |
|
|
|
<td >{0}</td> |
|
|
|
</tr> |
|
|
|
", "采购员邮箱:" + PurMail);
|
|
|
|
|
|
|
|
mailMessage += string.Format(@"
|
|
|
|
<tr> |
|
|
|
<td >{0}</td> |
|
|
|
</tr> |
|
|
|
", "采购经理邮箱:yu.zhou@panawincn.com");
|
|
|
|
|
|
|
|
mailMessage += @" </table></body></html>"; |
|
|
|
|
|
|
@ -293,10 +333,15 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI |
|
|
|
|
|
|
|
|
|
|
|
client.Send(message);//发送邮件
|
|
|
|
|
|
|
|
message.Dispose(); |
|
|
|
File.Delete(fileName); |
|
|
|
File.Delete(_NewFile); |
|
|
|
File.Delete(__NewFile); |
|
|
|
this.CloseDialog(); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
message.Dispose(); |
|
|
|
File.Delete(fileName); |
|
|
|
File.Delete(_NewFile); |
|
|
|
File.Delete(__NewFile); |
|
|
@ -304,17 +349,8 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI |
|
|
|
throw new Exception(ex.ToString()); |
|
|
|
|
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
message.Dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
File.Delete(fileName); |
|
|
|
File.Delete(_NewFile); |
|
|
|
File.Delete(__NewFile); |
|
|
|
|
|
|
|
|
|
|
|
this.CloseDialog(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -433,9 +469,25 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI |
|
|
|
throw new Exception("配置表Cust_PrintTemplateText中不存在对应信息,请先维护"); |
|
|
|
} |
|
|
|
|
|
|
|
_SelSQL = @"select c.DefaultEmail from PM_PurchaseOrder a
|
|
|
|
left join CBO_Operators b on a.PurOper = b.ID |
|
|
|
left join Base_Contact c on b.Contact = c.ID |
|
|
|
where a.DocNo ='" + CurrentState["POCode"].ToString() + "' and a.Org='" + CurrentState["OrgID"].ToString() + "'";
|
|
|
|
_SelSQLDs = new DataSet(); |
|
|
|
UFSoft.UBF.Util.DataAccess.DataAccessor.RunSQL(UFSoft.UBF.Util.DataAccess.DataAccessor.GetConn(), _SelSQL.ToString(), null, out _SelSQLDs); |
|
|
|
DataTable dtPur = new DataTable(); |
|
|
|
dtPur = _SelSQLDs.Tables[0]; |
|
|
|
if (dtPur.Rows.Count == 0) |
|
|
|
{ |
|
|
|
throw new Exception("采购员未维护邮箱"); |
|
|
|
} |
|
|
|
|
|
|
|
string PurMail = dtPur.Rows[0]["DefaultEmail"].ToString();//采购员收件邮箱
|
|
|
|
|
|
|
|
|
|
|
|
this.MailTitle86.Text = MaileTile; |
|
|
|
this.MailText53.Text = dt.Rows[0][0].ToString(); |
|
|
|
this.MailText53.Text = dt.Rows[0][0].ToString() + "\r\n" + "采购员邮箱:" + PurMail |
|
|
|
+ "\r\n" + "采购经理邮箱:yu.zhou@panawincn.com"; |
|
|
|
|
|
|
|
this.DataCollect(); |
|
|
|
this.DataBind(); |
|
|
|