<%@ WebHandler Language="C#" class="Handler" %>
using System;
using System.Web;
using Utility;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/plain";
string smtp = HttpContext.Current.Request.Form["smtp"].ToString();
string title = HttpContext.Current.Request.Form["title"].ToString();
string content = HttpContext.Current.Request.Form["content"].ToString();
string from = HttpContext.Current.Request.Form["from"].ToString();
string to = HttpContext.Current.Request.Form["to"].ToString();
try
{
EmailClient emailClient = new EmailClient(smtp);
emailClient.SendEmail(from, to, title, content);
System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
System.Collections.Generic.Dictionary<string, object> d = new System.Collections.Generic.Dictionary<string, object>();
d.Add("message", "success");
d.Add("success", true);
context.Response.Write(jss.Serialize(d));
}
catch (Exception ex)
{
System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
System.Collections.Generic.Dictionary<string, object> d = new System.Collections.Generic.Dictionary<string, object>();
d.Add("message", ex.Message);
d.Add("success", true);
context.Response.Write(jss.Serialize(d));
}
}
public bool IsReusable {
get {
return false;
}
}
}
发表评论