[英]send username in email
我在用户各自的电子邮件地址中发送邮件,当他收到邮件时,他会在这样的邮件中看到信息
docname = abc status =拒绝
现在我还想添加用户名并想显示谁批准他们的文档
我将用户名保存在会话中,然后当任何用户登录时,他/她的名称将显示在右上角短号中,我将这个名称保存在会话中
Session["Login2"] = txt_username.Value;
现在假设主管通过他们的帐户登录并批准任何文件并发送邮件,那么当用户收到邮件时,他将能够看到这样的邮件
docname= abc
status=reject
username = john
电邮代码
string DocName = ((Label)Repeater2.Items[i].FindControl("DocName")).Text;
string emailId =
((Label)Repeater2.Items[i].FindControl("YourEamil")).Text;
DropDownList dropdownvalue =
((DropDownList)Repeater2.Items[i].FindControl("DropDownList4"));
string docname = String.Empty;
string emailID = String.Empty;
string dropdownvalues = String.Empty;
if (DocName.ToString() != "")
{
docname = DocName.ToString();
}
else
{
docname = "Unavailable";
}
if (emailId.ToString() != "")
{
emailID = emailId.ToString();
}
else
{
emailID = "Unavailable";
}
if (dropdownvalue.SelectedItem.ToString() != "")
{
dropdownvalues = dropdownvalue.SelectedItem.ToString();
}
else
{
dropdownvalues = "Unavailable";
}
SendEmailUsingGmail(DocName, emailId, dropdownvalues);
cmd.ExecuteNonQuery();
}
}
else
{
Supvisor.Text = "Error";
}
if (mySQLconnection.State == ConnectionState.Open)
{
mySQLconnection.Close();
}
}
private void SendEmailUsingGmail(string DocName, string emailId, string
dropdownvalue)
{
try
{
SmtpClient smtp = new SmtpClient();
smtp.Credentials = new NetworkCredential("ketyycute@gmail.com", "123213");
smtp.Port = 587;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
MailMessage message = new MailMessage();
message.From = new MailAddress("ketyycut@gmail.com");
message.To.Add(emailId);
//message.To.Add(New MailAddress(toEmailAddress));
message.Subject = "Document Managment System=" + "DropDownList4" + dropdownvalue;
message.Body = "DocName=" + DocName + " DropDownList4=" + dropdownvalue;
smtp.Send(message);
}
catch (Exception ex)
{
Response.Write("Error occured: " + ex.Message.ToString());
}
}
我是怎么做到的
您具有在Session中批准它的人的用户名。 要检索此:
string approver;
if (Session["Login2"] != null)
{
approver = Session["Login2"].ToString();
}
如果您还想要电子邮件中批准文档的创建者/所有者的名称,则不需要在创建文档时存储它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.