想在网站上做个将留言发送到邮箱的模块
上网查了下说是用jmail
测试了好久一直没有成功
还望给位大牛指点
为了给大牛测试用请不要更改测试邮箱密码<html><head>    <title>mail</title>    <script>    function SendEMail(subject,infor)    {        var jMail = new ActiveXObject("Jmail.message");        jMail.Silent = true;

jMail.ISOEncodeHeaders = false;        jMail.Charset = "gb2312";        jMail.FromName = "from name";        jMail.From = "[email protected]";        jMail.AddRecipient("[email protected]");        jMail.Subject = subject;        jMail.Body = infor;        jMail.MailServerUserName="guoyu_bo";        jMail.MailServerPassWord="13579a";        var ret = jMail.Send("smtp.21cn.com");        if(ret == false)
        {            alert("fail");        }
        else
        {            alert("success");        }
        jMail.Close();
    }
SendEMail('title','body');
        </script></head>
</html>

解决方案 »

  1.   

    在页面直接调用 ActiveXObject("Jmail.message") 的话,要客户端装Jmail,并要有权限。
    一般都是在后台程序中发送的。另外,一般公共的邮件服务器为防止垃圾邮件,不支持直接用jmail发送邮件的。
    先用企业邮件服务器试试看。
      

  2.   

    Jmail是在服务器端运行的,可将要发送的内容提交到服务器后程序发送。
      

  3.   

    to hookee
    我现在是在本地装有jmail的客户端测试,所以发送失败有可能的原因是
    1.没设置好权限-》设置哪方面的权限呢?怎么设置?
    2.21cn不支持jmail发送邮件-》有没支持的公共邮件服务器呢?先前也试过我们公司的邮箱貌似也不成功to liaitan
    把Jmail放在服务器端运行,是不是要把html换成asp来弄,我现在刚用dreamweaver,不知有没必要换成vs
      

  4.   

    别用Jmail了,  using System.Net.Mail;        /// <summary>
            /// 用于发邮件的方法
            /// </summary>
            /// <param name="username">显示的发件人名称</param>
            /// <param name="subject">显示的主题名称</param>
            /// <param name="toname">收件人邮箱号码</param>
            /// <param name="body">内容</param>
            public static void SendMessage(string username, string subject, string toname, string body)
            {
                MailAddress from = new MailAddress("[email protected]", username);
                MailMessage mail = new MailMessage();
                mail.Subject = subject;
                mail.From = from;
                //设置邮件的收件人
                string address = "";
                string displayName = "";            string[] mailNames = (toname + ";").Split(';');
                foreach (string name in mailNames)
                {
                    if (name != string.Empty)
                    {
                        if (name.IndexOf('<') > 0)
                        {
                            displayName = name.Substring(0, name.IndexOf('<'));
                            address = name.Substring(name.IndexOf('<') + 1).Replace('>', ' ');
                        }
                        else
                        {
                            displayName = string.Empty;
                            address = name.Substring(name.IndexOf('<') + 1).Replace('>', ' ');
                        }
                        mail.To.Add(new MailAddress(address, displayName));
                    }
                }
                //设置邮件的内容
                mail.Body = body;
                //设置邮件的格式
                mail.BodyEncoding = System.Text.Encoding.UTF8;
                mail.IsBodyHtml = true;
                //设置邮件的发送级别
                mail.Priority = MailPriority.Normal;
                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
                SmtpClient client = new SmtpClient();
                //设置用于 SMTP 事务的主机的名称,填IP地址也可以了
                client.Host = "smtp.163.com";
                //设置用于 SMTP 事务的端口,默认的是 25
                //client.Port = 25;
                client.UseDefaultCredentials = false;
                //这里才是真正的邮箱登陆名和密码,比如我的邮箱地址是 hbgx@hotmail, 我的用户名为 hbgx ,我的密码是 xgbh
                client.Credentials = new System.Net.NetworkCredential("邮箱帐号", "密码");
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                //都定义完了,正式发送了,很是简单吧!
                client.Send(mail);
            }
      

  5.   

    如果你需要实际应用该程序,肯定是要改到服务器端的,否则难道使用这个应用的用户都要在客户端安装jmail,这个要求不太现实吧。所以改到服务器端再试试吧。
      

  6.   

    <SCRIPT LANGUAGE="VBScript" RUNAT="Server">
    sub sendMail() Set jmail = Server.CreateObject("Jmail.message")
     Response.Write("af") 
     jmail.silent = true 
     jmail.logging = true 
     jmail.ContentType = "text/html" 
     jmail.Charset = "gb2312"  jmail.From ="[email protected]" '发信邮箱
     jmail.FromName="adsf" '发信网站  
     jmail.MailServerUserName = "guoyu_bo" '发信邮箱用户名 
     jmail.MailServerPassword = "13579a" '发信邮箱密码 
     jmail.AddRecipient "[email protected]"
     jmail.Subject = "[email protected]"
     jmail.HtmlBody = "[email protected]"
     jmail.ServerAddress="smtp.21cn.com"     '用来发送邮件的SMTP服务器
     jmail.Send("smtp.21cn.com") 
     jmail.Close()end subcall sendMail
    </SCRIPT>
    改成后台了还是不能发送啊
      

  7.   

    <SCRIPT LANGUAGE="VBScript" RUNAT="Server">
    sub sendMail() Set jmail = Server.CreateObject("Jmail.message")
     Response.Write("af") 
     jmail.silent = true 
     jmail.logging = true 
     jmail.ContentType = "text/html" 
     jmail.Charset = "gb2312"  jmail.From ="[email protected]" '发信邮箱
     jmail.FromName="adsf" '发信网站  
     jmail.MailServerUserName = "guoyu_bo" '发信邮箱用户名 
     jmail.MailServerPassword = "13579a" '发信邮箱密码 
     jmail.AddRecipient "[email protected]"
     jmail.Subject = "[email protected]"
     jmail.HtmlBody = "[email protected]"
     jmail.ServerAddress="smtp.21cn.com"     '用来发送邮件的SMTP服务器
     jmail.Send("smtp.21cn.com") 
     jmail.Close()end subcall sendMail
    </SCRIPT>改成后台运行还是不行啊
      

  8.   

    但那服务器支持jmail不支持.net啊