在C#中,如何使用POP3来接收邮件的附件(将邮件正文和附件分开)

解决方案 »

  1.   

    http://www.sxsky.net/it/html/20051042348.htm
      

  2.   

    感谢 anmeier,我是要用C#来写winForm,我现在能够收到邮件,但邮件内容和附件是混在一起的,请问怎么分开。
                       public MailMessage GetNewMessages(int nIndex)
    {
    int newcount;
    System.Web.Mail.MailMessage msg = new MailMessage(); try
    {
    newcount = GetNumberOfNewMessages();
    Connect();
    int n = nIndex+1; if(n<newcount+1)
    {
    ArrayList msglines = GetRawMessage(n);
    string msgsubj = GetMessageSubject(msglines);
                    
                        
    msg.Subject = msgsubj;
    msg.From = GetMessageFrom(msglines);
    msg.Body = GetMessageBody(msglines);
    } Disconnect();
    return msg;
    }
    catch
    {
    return null;
    }
    }
                      private string GetMessageBody(ArrayList msglines)
    {
    string body = "";
    string line = " ";
    IEnumerator msgenum = msglines.GetEnumerator(); while(line.CompareTo("") != 0)
    {
    msgenum.MoveNext();
    line = (string)msgenum.Current;
    } while (msgenum.MoveNext() )
    {
    body = body + (string)msgenum.Current + "\r\n";
    }
    return body;
    }