当前位置:编程学习 > C#/ASP.NET >>

使用SmtpClient发送邮个,提示:命令顺序不正确

我用以下方法发送邮件,目前使用smtp( smtp.qq.com, smtp.163.com )都可以正常象别的邮箱发送邮件。但如果换成公司的SMTP就发不了。返回的信息是:命令顺序不正确  。这是怎么回事呢?

        /// <summary>
        /// 发送邮件程序
         /// </summary>
        /// <param name="toadd">目的地址</param>
        /// <param name="sb">内容</param>
        /// <param name="subject">主题</param>
        /// <returns></returns>
        public bool sendemail(string toadd, string sb, string subject)
        {
            try
            {
                string SendUserMail = "test@公司域名.com";
                //用于发送邮件的地址。 
                   MailAddress from = new MailAddress(SendUserMail);
                //目的地址
                MailAddress to = new MailAddress(toadd);
                MailMessage message = new MailMessage(from, to);
                //主题 
                message.Subject = subject;
                message.Attachments.Add(new Attachment(@"c:/test.txt"));

                message.IsBodyHtml = true;
                //正文 
                message.Body = sb;
                //设置smtp服务器。 

                string smtp = "smtp.preamsolutions.com";
                SmtpClient client = new SmtpClient(smtp);

                string user = "test";
                string pwd = "test123";
                client.Credentials = new System.Net.NetworkCredential(user, pwd);
                //client.EnableSsl = true;

                client.Send(message);
                client = null;
                message.Dispose();
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        } --------------------编程问答-------------------- 大家帮帮忙呀,自己顶一下
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,