WriteStream("--unique-boundary-2");
                WriteStream("Content-Type:   text/plain;charset=" + this.charset);
                WriteStream("Content-Transfer-Encoding:" + this.encode);
                WriteStream("");
                WriteStream(body);
                WriteStream(" ");//一个部分写完之后就写如空信息,分段                   WriteStream("--unique-boundary-1--");
                if (!OperaStream(".", "250"))//最后写完了,输入“.”  
                {
                    MessageBox.Show("发送失败!");
                    this.Close();   //关闭连接   
                }用socket smtp发送邮件C#我发邮件的这样发的,在最后输入“.”后返回250是正确的,但是去返回了Error 502,其他返回都是正确,就最后结束这个“.”错误,怎么回事啊?有没有哪个大哥知道额!!

解决方案 »

  1.   


     SmtpClient client = new SmtpClient(args[0]);
                // Specify the e-mail sender.
                // Create a mailing address that includes a UTF8 character
                // in the display name.
                MailAddress from = new MailAddress("[email protected]", 
                   "Jane " + (char)0xD8+ " Clayton", 
                System.Text.Encoding.UTF8);
                // Set destinations for the e-mail message.
                MailAddress to = new MailAddress("[email protected]");
                // Specify the message content.
                MailMessage message = new MailMessage(from, to);
                message.Body = "This is a test e-mail message sent by an application. ";
                // Include some non-ASCII characters in body and subject.
                string someArrows = new string(new char[] {'\u2190', '\u2191', '\u2192', '\u2193'});
                message.Body += Environment.NewLine + someArrows;
                message.BodyEncoding =  System.Text.Encoding.UTF8;
                message.Subject = "test message 1" + someArrows;
                message.SubjectEncoding = System.Text.Encoding.UTF8;
                // Set the method that is called back when the send operation ends.
                client.SendCompleted += new 
                SendCompletedEventHandler(SendCompletedCallback);
                // The userState can be any object that allows your callback 
                // method to identify this send operation.
                // For this example, the userToken is a string constant.
                string userState = "test message1";
                client.SendAsync(message, userState);
                Console.WriteLine("Sending message... press c to cancel mail. Press any other key to exit.");
                string answer = Console.ReadLine();
                // If the user canceled the send, and mail hasn't been sent yet,
                // then cancel the pending operation.
                if (answer.StartsWith("c") && mailSent == false)
                {
                    client.SendAsyncCancel();
                }
                // Clean up.
                message.Dispose();
                Console.WriteLine("Goodbye.");
      

  2.   

    使用 System.Net.Mail.SmtpClient比较简单,都封装好了
      

  3.   

    你可以找一个smtp协议文本看看,编号:RTFC 821!句点十有八九是邮件结束符号,因此正文中用句点结束,需要转义,例如变成两个句点。自己看看协议再编程。
      

  4.   


    这位大哥,smtp协议是说的一“.”号结束发送内容,结束此次发送,我就不明白,我发送“.”号就返回502错误!