急求,我测试了一个,直接在对方邮件里显示的 <html> <body> <iframe  src="http://www.xxx.com/xx.aspx" ></iframe> </body> </html>求一个.net 1.1 版本的能发送个网页的代码,2.0和以上的代码就不用了,1.1下不好使 .谢谢了

解决方案 »

  1.   

    邮件正文最好不要用iframe,好多邮件服务器都过滤他,担心iframe网页有毒
      

  2.   


    public static bool sendMail(string to, string from, string subject, string message)
    {
    System.Web.Mail.MailMessage Message = new System.Web.Mail.MailMessage();
    Message.To = to.Replace(",", ";");
    Message.From = from;
    Message.Subject = subject;
    Message.Body = message;
    Message.BodyFormat = System.Web.Mail.MailFormat.Html;

    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);//基本权限

    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username");//用户名

    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");//密码

    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);

    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendserver", "smtp.sina.com");

    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", false);//SSL
    try
    {
    System.Web.Mail.SmtpMail.Send(Message);
    return true;
    }
    catch
    {
    return false;
    }
    }
      

  3.   

    Message.BodyFormat = System.Web.Mail.MailFormat.Html;
    加上这句即可如果你要发送<iframe> or <script>恐怕不行,安全过滤
      

  4.   

      jmail.Message j = new jmail.Message();
             
                        String Subject = "";
                        String body = "" ;
                        String FromEmail = "[email protected]";
                        String ToEmail = dr["Email"].ToString();
                        j.Silent = true;
                        j.Logging = true;
                          j.ContentType = "text/html";
                        j.AddRecipient(ToEmail, "", "");
                        j.From = FromEmail;
                        j.MailServerUserName = "";
                        j.MailServerPassWord = "123456";
                        j.Subject = Subject;
                        j.Body = body + "<br>"+t.ToString();
                        j.Send("smtp.163.com", false);
                        j.Close();
                      iframe可能禁止
      

  5.   

    楼上的方法可以了,既然是网页就要选html模式,内容自己拼写或直接读取个模板
    下面一个读取模板发送的的例子,一般模板做些标记标记,之后替换内容,另外发送到邮箱的网页不要用JS,iframe
    另外css也要写在页里面,不要引用,图片的src要加上全路径,邮箱里是不是自动找到你服务器里的图片的,如
    <img src="http://www.123.com/images/001.gif" width="190" height="95">不能写成
    <img src="images/001.gif" width="190" height="95">string str="";
    Encoding code=Encoding.GetEncoding("gb2312");
    string temp=Server.MapPath("html/1.html"); //模板页放在html下的1.html
    StreamReader sr=null;
    //读取模板
    try
    {
    sr=new StreamReader(temp,code);
    str=sr.ReadToEnd();
    }
    catch(Exception exp)
    {
    Response.Write(exp.Message);
    Response.End();
    sr.Close();
    }

    sr.Close();
    //下面这2个是在网页里做的标记,我的是发新闻,myTitle,myText好 2个字段是放新闻标题和内容的
    //str=str.Replace("myTitle","测试标题-防爆电器测试");
    //str=str.Replace("myText","测试一些产品的信息我就测试测试一些产品的信息我就测试测试一些产品的信息我就测试测试一些产品的信息我就测试测试一些产品的信息我就测试测试一些产品的信息我就测试测试一些产品的信息我就测试测试一些产品的信息我就测试测试一些产品的信息我就测试测试一些产品的信息我就测试测试一些产品的信息我就测试");


    MailMessage message = new MailMessage();
    message.To = "[email protected]";
    message.Priority = MailPriority.High;
    message.From = "[email protected]";
    message.Subject = "标题";
    message.BodyFormat = MailFormat.Html;
    message.Body = str;
    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "用户用");
    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "密码");
    SmtpMail.SmtpServer = "smtp.163.com";
    try
    {
    SmtpMail.Send(message);
    base.Response.Write("<script>alert('提交成功!')</script>");

    }
    catch
    {
    base.Response.Write("<script>alert('提交失败!')</script>");
    }
      

  6.   

    少说了3引用using System.Web.Mail; 
    using System.Text;
    using System.IO;