日期:2014-05-18  浏览次数:20852 次

请问用jmail发邮件时,老提示失败,怎么回事啊?
C# code

          MessageClass email = new MessageClass();          
          email.MailServerUserName = "zj0000rd";
          email.MailServerPassWord = "***";
          email.From = "zj0000rd@163.com";   
          email.Subject = "jmail";    
          email.Body = "test jmail send mail";
          email.AddRecipient("zj0000rd@163.com", "", "");
          email.Send("mail.163.com", false);



------解决方案--------------------
那你要知道163.com邮件服务器的smtp的设置才行。
------解决方案--------------------
要把用户名和密码引用上,否则无法自动登录信箱的,有个例子你看看


C# code

   tring FromMail = "tangsiyanking@sina.com";//发件人 
            string Title = "test"; //邮件主题 
            string Body = "test";   //邮件主体 
            string ShowName = "paladintsy";//显示名字 
            string MailUserName = "tangsiyanking"; 
            string MailPassword = "xxxxxx";//密码就不给了.... 
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); 
            msg.From = new MailAddress(FromMail,ShowName,System.Text.Encoding.GetEncoding("GB2312")); 
            msg.Subject = Title;//邮件标题  
            msg.Body = Body;//邮件内容  
            msg.Priority = MailPriority.Normal;//邮件优先级   
            msg.SubjectEncoding = System.Text.Encoding.GetEncoding("GB2312");//标题编码 
            msg.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");//正文编码 
            msg.To.Add("seu_tangsiyan@qq.com"); 

             System.Net.Mail.Attachment attTemp = new System.Net.Mail.Attachment("C:\\Documents and Settings\\HellKnight\\My Documents\\My Pictures\\profile.txt"); 

            attTemp.NameEncoding = System.Text.Encoding.GetEncoding("GB2312");//附件名编码 
            msg.Attachments.Add(attTemp); 
.....................................................