本文介绍了如何将会话传递给电子邮件管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是,我必须发送带有会话变量的邮件。
我有一个带会话变量的文本框。
My problem is, I have to send mail with session variable.
I have a textbox with session variable.
<input type="search" name="txtValue" id="txtValue" value="@Session["searched"]" placeholder="Need Service ? >
我需要将会话变量传递给电子邮件管理员
代码
I need to pass session variable to Email manager
Code
public class Alert
{
private const string EmailFrom = "XXX@gmail.com";
public static void SendConfirmationEmailAlert(string alert_text_box)
{
using (var client = new SmtpClient())
{
using (var message = new MailMessage(EmailFrom, alert_text_box))
{
message.Subject = "Please Verify Your Account";
message.Body = "<html><head><meta content=\"text/html; charset=utf-8\" /></head><body><p>Dear " + alert_text_box +
", </p><p>Thankyou for Alert </p>"
+ "</a></p><div>Best regards,</div><div>Jajin</div><p>Do not forward "
+ "this email. The verify link is private.</p></body></html>";
message.IsBodyHtml = true;
client.EnableSsl = true;
client.Send(message);
};
};
}
}
如何将@Session [搜索]传递给身体邮件(message.Body)。我的意思是我想发送带有会话变量的邮件。我该如何解决这个问题?
推荐答案
//If the values are in the cookie, then you can just write the cookie value to a string and plug it in. The session itself cannot be sent as it will be encrypted, but you can send the value(s) that it contains as shown below.
string cookieValue = Session["searched"]).ToString();
message.Body = "Dear " + cookieValue + ". Thankyou for Alert<br /><br />Best regards, Jalin<br /><br />Do not forward this email. the verify link is private.";
这篇关于如何将会话传递给电子邮件管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!