RT: 如题 jmail  发送邮件如何实现自定义模板(背景)

解决方案 »

  1.   

    你可以参考一下jmail 的开发手册,上面说的比较详细。
    我也用过,不过没有做过你说的这种。不好意思。
      

  2.   

    先祝各位csdn朋友新年快乐~ 
     然后抢分 呵呵 ~
      

  3.   

    你找个jmail的开发手册好好看看~~~~要么你就详细的说一下你想要怎么实现你的自定义模板。
      

  4.   

    模板偶没写过,不过偶是自己用HTML语言直接放到他的HTMLBody里面,,
    实现的。
      

  5.   

    private void btnOk_Click(object sender, System.EventArgs e)
    {
    jmail.Message oJmailMessage = new jmail.Message();
    jmail.POP3Class popMail = new POP3Class();
    oJmailMessage.MailServerUserName = txtEmailName.Text.Trim();
    oJmailMessage.MailServerPassWord = txtEmailPwd.Text.Trim();

    try
    {
    popMail.Connect(oJmailMessage.MailServerUserName,oJmailMessage.MailServerPassWord,txtEmailPop3.Text.Trim(),Convert.ToInt32(txtPort.Text.Trim()));
    oJmailMessage.From = ConfigurationSettings.AppSettings["EmailAddr"];
    oJmailMessage.FromName  = ConfigurationSettings.AppSettings["EmailSendName"];
    oJmailMessage.Subject  = ConfigurationSettings.AppSettings["Emailsubject"];
    // oJmailMessage.Body = ConfigurationSettings.AppSettings["Emailbody"];
    string url = Server.MapPath("../")+"images/bg/temple.jpg";
    string contentId = oJmailMessage.AddAttachment(url,true,"image/jpg");
    oJmailMessage.HTMLBody = "<html><head><META content=zh-cn http-equiv=Content-Language><meta http-equiv=''''Content-Type''''content=''''text/html; charset=gb2312''''><style type=text/css>A:link { FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #000000}A:visited {FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #666666}A:hover {COLOR: #ff6600; FONT-SIZE: 9pt; TEXT-DECORATION: underline}BODY {FONT-SIZE: 9pt} --></style></head><body  BACKGROUND=\"cid:'"+contentId   +   "'\"><font color=green>" + ConfigurationSettings.AppSettings["Emailbody"] + "</font></body></html>";
    oJmailMessage.Body = ConfigurationSettings.AppSettings["Emailbody"]; oJmailMessage.Charset = "GB2312";
    oJmailMessage.Encoding = "BASE64";
    oJmailMessage.ISOEncodeHeaders = false;
    oJmailMessage.Priority = Convert.ToByte(1);
    oJmailMessage.AddRecipient(txtEamilAddr.Text.Trim(),ConfigurationSettings.AppSettings["EmailSendName"],"");
    oJmailMessage.MailServerUserName = ConfigurationSettings.AppSettings["EmailName"];
    oJmailMessage.MailServerPassWord = ConfigurationSettings.AppSettings["EmailPwd"];
    oJmailMessage.AddRecipient(txtEamilAddr.Text.Trim(),"","");
    if(oJmailMessage.Send(ConfigurationSettings.AppSettings["Smtp"],false))
    {
    if(lblMailId.Text == "")
    {
    string sql = "...";
    if(db.Exec(sql) != -1)
    {
    utility.Method.ExampleJavascript(Page,"設置成功","emailIndex.aspx");
    }
    else
    {
    Response.Redirect("../Error.aspx");
    }
    }
    else
    {
    string sql = "...";
    if(db.Exec(sql) != -1)
    {
    utility.Method.ExampleJavascript(Page,"修改成功","emailIndex.aspx");
    }
    else
    {
    Response.Redirect("../Error.aspx");
    }
    }
    }
    else
    {
    utility.Method.ExampleJavascript(Page,"测试失败!",true);
    }
    }
    catch
    {
    utility.Method.ExampleJavascript(Page,"测试失败!",true);
    }
    finally
    {
    oJmailMessage = null;
    }
    }
    #endregion