日期:2014-05-19  浏览次数:20945 次

用socket写的发送邮件的程序 没有内容?高分
以下是我的代码,   能够收到邮件,   但就是内容没有。   不知道为什么?
是协议不对吗?

public   void   SendMail(MailMessage   msg)
{
NetworkStream   nwstream   =   GetConnection();
CheckForError(ReadFromStream(ref   nwstream),   ReplyConstants.HELO_REPLY);

WriteToStream(ref   nwstream,   "EHLO   "   +   SmtpConfig.SmtpHost   +   "\r\n ");
string   welcomeMsg   =   ReadFromStream(ref   nwstream);
CheckForError(welcomeMsg,   ReplyConstants.OK);

//   implement   HELO   command   if   EHLO   is   unrecognized.
// if   (IsUnknownCommand(welcomeMsg))
//{
// WriteToStream(ref   nwstream,   "HELO   "   +   SmtpConfig.SmtpHost   +   "\r\n ");
// }
// CheckForError(welcomeMsg,   ReplyConstants.OK);

//   Authentication   is   used   if   the   u/p   are   supplied
AuthLogin(ref   nwstream);

WriteToStream(ref   nwstream,   "MAIL   FROM:   < "   +   msg.From   +   "> \r\n ");
CheckForError(ReadFromStream(ref   nwstream),   ReplyConstants.OK);

SendRecipientList(ref   nwstream,   msg.To);
SendRecipientList(ref   nwstream,   msg.Cc);
SendRecipientList(ref   nwstream,   msg.Bcc);

WriteToStream(ref   nwstream,   "DATA\r\n ");
CheckForError(ReadFromStream(ref   nwstream),   ReplyConstants.START_INPUT);


if   (msg.From   != " "   &&   msg.From.Length   !=   0)
{
    WriteToStream(ref   nwstream,   "From:   "   +   msg.From   +   "\r\n ");  
}

WriteToStream(ref   nwstream,   "To:   "   +   msg.To   +   "\r\n ");

if   (msg.Cc   !=   null)
{
WriteToStream(ref   nwstream,   "CC:   "   +   msg.Cc   +   "\r\n ");  
}

WriteToStream(ref   nwstream,   "Subject:   "   +   msg.Subject   +   "\r\n ");
//WriteToStream(ref   nwstream,   "X-Priority:   "   +   msg.Priority.ToString()   +   "\r\n ");  
WriteToStream(ref   nwstream,   msg.Body   +   "\r\n ");  

WriteToStream(ref   nwstream,   "\r\n.\r\n ");
CheckForError(ReadFromStream(ref   nwstream),   ReplyConstants.OK);


WriteToStream(ref   nwstream,   "QUIT\r\n ");
CheckForError(ReadFromStream(ref   nwstream),   ReplyConstants.QUIT);
CloseConnection();
}

------解决方案--------------------
没做过,帮顶
------解决方案--------------------
不清楚啊……
帮顶上去啊……
------解决方案--------------------
既然知道了,那我就接分好了...
------解决方案--------------------
已经知道了 ?

JF ~

啊哈哈~
------解决方案--------------------
本人曾经结果POP3邮件获取发送VB