在asp.net中,我使用system.web.mail进行Email发送,但是
我想将数据库中的数据以固定格式Email出去,整个过程全自动,应该如何实现?

解决方案 »

  1.   

    要像自动就在Global里面写好了..
      固定格式,你个用代码写.比如些个table 发出去的时候,就会有格式了.
      

  2.   

    写个控制台程序发送邮件。。
    把格式做成html,html包含很多标签。
    读html文件并用数据库中的内容替换标签
    window计划任务
      

  3.   

    try
                {
                    string Noempty = "<p class=\"plaintext\">Personal message: <br />" + this.txtMessage.Text + "</p>";
                    string template = WebUtil.ReadTemplate(ConfigurationManager.AppSettings["TemplatePath"] + "emailTemplate.htm");
                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("{0} ({1}) has forwarded you a page from the InnoCentive website.", this.txtUserName.Text, this.txtEmail.Text);
                    sb.Append("<br><br>");
                    if (!String.IsNullOrEmpty(this.txtMessage.Text))
                    {
                        sb.Append("Personal Message:");
                        sb.Append("<br>");
                        sb.Append(this.txtMessage.Text);
                        sb.Append("<br><br>");
                    }
                    sb.Append(this.url.Substring(this.url.LastIndexOf(@"\") + 1));
                    sb.Append("<br>");
                    sb.Append("<a href=\"" + this.url + "\">" + this.url.Substring(this.url.LastIndexOf(@"\") + 1) + "</a>");
                    sb.Append("<br><br>");
                    sb.Append("www.innocentive.com");                WebUtil.SendEmail(this.txtFriendEmail.Text, this.txtEmail.Text, this.txtUserName.Text + " has forwarded you a page from InnoCentive.com.", sb.ToString());
                    Response.Write("<script>alert('send successfully');</script>");
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
      

  4.   

    static public string ReadTemplate(string filePath)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                using (StreamReader tempReader = new StreamReader(filePath, Encoding.UTF8))
                {
                    string line;
                    while ((line = tempReader.ReadLine()) != null)
                    {
                        sb.Append(line);
                    }
                    tempReader.Close();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return sb.ToString();
        }