简体   繁体   English

通过 ASP.Net 页面加载发送电子邮件

[英]Send Email Through ASP.Net Page Load

I am attempting to pass parameters to an asp.net webpage and as soon as the page loads take those parameters and pass them to an email and have the email send.我正在尝试将参数传递给 asp.net 网页,并且在页面加载后立即获取这些参数并将它们传递给电子邮件并发送电子邮件。
My page loads fine, my email sends fine, but it seems the parameters are being lost somewhere along the way (or maybe not even actually being passed).我的页面加载正常,我的电子邮件发送正常,但似乎参数在途中丢失了(或者甚至可能实际上没有被传递)。
Could someone with some more knowledge on this matter assist me?对这件事有更多了解的人可以帮助我吗?

Code Behind:背后的代码:

protected void Page_Load(object sender, EventArgs e)
{       
    String userID = Request.QueryString["userID"];
    String employeename = Request.QueryString["employeename"];
    String jobsite = Request.QueryString["jobsite"];

    MailMessage msg = new MailMessage();
    msg.From = new MailAddress("aspTest14871112@gmail.com");
    msg.To.Add(new MailAddress("diditwork@gmail.com"));
    msg.Subject = "Test Email From AsP.NET";
    msg.Body = userID + " " + employeename + " " + jobsite;
    msg.Priority = MailPriority.Normal;
    msg.IsBodyHtml = true;
    SmtpClient c = new SmtpClient(sSMTPServer);
    c.Send(msg);
}

Actual site going to with attempting to pass parameters:尝试传递参数的实际站点:

http://www.internalwebsite/testing/autogenerate.aspx?userID=TOSTRING(userID)&employeename=employeename&jobsite=jobsite http://www.internalwebsite/testing/autogenerate.aspx?userID=TOSTRING(userID)&employeename=employeename&jobsite=jobsite

我相当肯定,如果您将 TOSTRING(userID) 更改为 userID.ToString(),您将获得这些值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM