2010-06-30 145 views
2

.net有一個用於發送郵件的SMTP客戶端 但沒有用於閱讀郵件的pop3客戶端。 香港專業教育學院之前使用WEBDAV,但我真的希望有一個簡單的POP3或IMAP客戶端那穩定.Net POP3客戶端

我知道好像是的例子10000,但爲什麼沒有官方的.NET客戶端,如果他們做了一個SMTP客戶端

任何想法?

+1

請參閱[使用C#中的Pop3閱讀電子郵件](http://stackoverflow.com/questions/44383/reading-email-using-pop3-in-c) – 2010-06-30 13:55:10

回答

4

The F#.NET Journal文章An e-mail client in F#(31日2010年3月)介紹瞭如何編寫自己在F#代碼短短的幾行,圍繞以下順序表達中心:

> let receive = 
    seq { use client = new Sockets.TcpClient(Server.pop3.addr, Server.pop3.port) 
      use stream = client.GetStream() 
      use reader = new System.IO.StreamReader(stream) 
      let rec readToDot() = 
      let line = reader.ReadLine() 
      if line <> "." then line + "\n" + readToDot() else "" 
      reader.ReadLine() |> ignore 
      use writer = new System.IO.StreamWriter(stream) 
      let write (line: string) = 
      writer.Write(line + "\n") 
      writer.Flush() 
      write "USER myname" 
      reader.ReadLine() |> ignore // +OK Password required. 
      write "PASS mypassword" 
      reader.ReadLine() |> ignore // +OK logged in. 
      write "STAT" 
      let stat = reader.ReadLine() // +OK <message count> <total size> 
      for i in 1 .. int (stat.Split[|' '|]).[1] do 
      write(sprintf "RETR %d" i) 
      reader.ReadLine() |> ignore // +OK <message size> octets follow. 
      match readToDot() |> parse with 
      | Some msg -> yield msg 
      | None ->() 
      write "QUIT" 
      reader.ReadLine() |> ignore };; 
val receive : seq<msg> 
3

This是我使用的庫。它很容易使用,沒有任何問題。