当邮件被触发时,在邮件中获取空白字段
本文关键字:获取 字段 空白 | 更新日期: 2023-09-27 18:30:16
下面是发送邮件的代码。我没有收到任何错误或异常,但是当邮件被触发时,我得到了区域名称,位置名称和合作伙伴代码的空白字段。还会显示合作伙伴名称。
if (objUser.UserMasterId == 0)
{
objUser.FunctionalityId = 10; //Partner Creation
dtPartnerMailDetails = UserMasterBL.GetPartnerMailDetails(objUser);
if (dtPartnerMailDetails.Rows.Count > 0)
{
objUser.RegionName = dtPartnerMailDetails.Rows[0]["RegionName"].ToString();
objUser.LocationName = dtPartnerMailDetails.Rows[0]["LocationName"].ToString();
objUser.PartnerCode = dtPartnerMailDetails.Rows[0]["PartnerCode"].ToString();
objUser.PartnerName = dtPartnerMailDetails.Rows[0]["partnername"].ToString();
}
dtMailDetails = UserMasterBL.GetMailDetails(objUser);
if (dtMailDetails.Rows.Count > 0)
{
string strMailFROM = "WiproIMSCertificationPortal@wipro.com";
string ToMailIds = dtMailDetails.Rows[0]["ToMailIds"].ToString();
string CCMailIds = dtMailDetails.Rows[0]["CCMailIds"].ToString();
/* string Region = dtPartnerMailDetails.Rows[0]["regionname"].ToString();
string Location = dtPartnerMailDetails.Rows[0]["locationname"].ToString();
string PartnerCode = dtPartnerMailDetails.Rows[0]["PartnerCode"].ToString();
string partnername = dtPartnerMailDetails.Rows[0]["partnername"].ToString();*/
string Region = objUser.RegionName;
string Location = objUser.LocationName;
string PartnerCode = objUser.PartnerCode;
string PartnerName = objUser.PartnerName;
//string partnercodeauto = objUser.PartnerCodeid;
string strmailBody = "<html><body><font face='Verdana' size=2 color=#0E6192>";
strmailBody += "Dear Administrator " + "<br/><br/>";
strmailBody += "Kindly approve below request, Created by " + objUser.PartnerName + "<br/> <br/>";
strmailBody += "<br/><br/>";
strmailBody += "<table border=1><tr><td><b>sl no </b></td><td><b>Region</b></td><td><b>Location</b></td><td><b>Partner Name</b></td><td><b>Partner Code</b></td>";
strmailBody += "<tr><td>1 </td><td>" + Region + "</td><td> " + Location + " </td><td>" + PartnerName + " </td><td>" + PartnerCode + " </td></tr></table>";
strmailBody += "<br/><br/>";
strmailBody += "</body></html>";
strmailBody += "Best Regards" + "<br/>" + " IMS Team";
strmailBody += "<br/><br/>";
strmailBody += "Disclaimer: This is a system generated mail. Please do not reply to this mail. For any queries, Please log a call in https://serviceconnect.wipro.com <br/>";
string strMailSubject = "Partner Addition " + objUser.PartnerCode + "";
Helper.Sendmail(strMailFROM, ToMailIds, strMailSubject, strmailBody, CCMailIds, null, null);
}
数据层代码:
public static DataTable GetPartnerMailDetails(UserMasterOL objUser)
{
if (objUser == null)
{
throw new ArgumentNullException("objUser");
}
DataTable dtGetPartnerMailDetails = new DataTable();
dtGetPartnerMailDetails.Locale = CultureInfo.InvariantCulture;
try
{
DbCommand DbCmd = DataAccessbase.Database.GetStoredProcCommand(Constants.GetPartnerCreationMailDetails);
DataAccessbase.Database.AddInParameter(DbCmd, "@PartnerCode", DbType.String, objUser.PartnerCode);
dtGetPartnerMailDetails = DataAccessbase.Database.ExecuteDataSet(DbCmd).Tables[0];
}
存储过程:
ALTER PROCEDURE [dbo].[GetPartnerCreationMailDetails]
(
@PartnerCode INT
)
AS
BEGIN
SET NOCOUNT ON
select rm.regionname,pm.PartnerCode,pm.partnername,lm.locationname from partnermaster pm
inner join regionmaster rm on
rm.regionid=pm.regionid
inner join locationmaster lm on
lm.locationid=pm.locationid
where pm.PartnerCode=@PartnerCode
end
尝试关闭此行上的 TR:
strmailBody += "<table border=1><tr><td><b>sl no </b></td><td><b>Region</b></td><td><b>Location</b></td><td><b>Partner Name</b></td><td><b>Partner Code</b></td>";
它应该是
strmailBody += "<table border=1><tr><td><b>sl no </b></td><td><b>Region</b></td><td><b>Location</b></td><td><b>Partner Name</b></td><td><b>Partner Code</b></td></tr>";