我的任务是在 asp.net c# 中构建休假管理应用程序,当员工填写所需的详细信息并按下申请按钮时,在休假申请中,邮件应发送给相应的经理说
“您好{经理},
{LoggedInUser} 已为 {NumofDays} 请求 {TypeofLeave} 请登录门户以接受或拒绝它
谢谢你。”
我可以收到邮件,但我需要的是代替 {Manager}、{TypeoLeave}、{NumofDays} 和 {LoggedInUser} 我需要各自的经理姓名、登录用户以及员工申请的休假类型和多少天。它应该从数据库中提取。
例如:“你好 ABC,
XYZ 已请病假 5 天请登录门户接受或拒绝
谢谢你。”
现在我得到与上面相同的结构。
请帮我。
protected void BtnApply_Click(object sender, EventArgs e)
{
MTMSDTO objc = new MTMSDTO();
int Flag = 0;
LblLogdInUser.Text = Session["EmpName"].ToString();
objc.LoggedInUser = LblLogdInUser.Text;
objc.TypeofLeave = DrpTypeofLeave.SelectedItem.Text;
string date;
date = Convert.ToDateTime(TxtBeginDate.Text).ToString("dd/MM/yyyy");
DateTime dt = new DateTime();
dt = Convert.ToDateTime(date);
objc.BeginDate = dt;
objc.EndDate = Convert.ToDateTime(TxtEndDate.Text);
objc.Description = TxtDescription.Text;
objc.NumofDays = Convert.ToInt32(TxtNumofDays.Text);
//objc.EmpName = LblLogdInUser.Text;
objc.Status = TxtStatus.Text;
int X = obj.InsertLeave(objc);
{
if (X >= 0)
{
Flag = 1;
}
else
{
Flag = 0;
}
}
if (Flag == 1)
{
LblSuccess.Visible = true;
LblSuccess.Text = "Data Added Successfully and Leave Application Succesfully Sent";
DrpTypeofLeave.ClearSelection();
TxtBeginDate.Text = "";
TxtEndDate.Text = "";
TxtDescription.Text = "";
TxtNumofDays.Text = "";
TxtStatus.Text = "";
}
else
{
LblErr.Visible = true;
LblErr.Text = "Failed To Add Data and Send Leave Request!!!";
}
objc.EmpName = Convert.ToString(Session["EmpName"]);
DataSet GrdLH = obj.GrdLeaveHistory(objc);
DataView GrdLeaveH = new DataView();
GrdLeaveH.Table = GrdLH.Tables[0];
GridViewLeaveHistory.DataSource = GrdLeaveH;
GridViewLeaveHistory.DataBind();
MailMessage message = new MailMessage();
message.To.Add("abcer@abc.in");
message.Subject = "Leave Request";
message.From = new MailAddress("abc@gmail.com");
message.IsBodyHtml = true;
message.Body = "<span style = font-family:Arial,font-size:10pt>";
message.Body += "Hello <b>{Manager}</b>,<br /><br />";
message.Body += "{LoggedInUser}has requested {TypeofLeave} for {NumofDays}";
message.Body += "kindly login to the portal to accept or reject it";
message.Body += "<br />";
message.Body += "<br />";
message.Body += "Thank You.<br />";
message.Body += "</span>";
SmtpClient smtp = new SmtpClient("");
smtp.Send(message);
}