开发者

.Net POP3 client [duplicate]

This question already has answers here: Closed 12 years ago.

.net has a SMTP client for sending mail but no pop3 client for reading mail. Ive used WEBDAV before, but I really want a simple pop开发者_JAVA技巧3 or imap client thats stable

I know there seems to be 10000 of examples, but why no offical .net client if they made a SMTP client

any thoughts?


The F#.NET Journal article An e-mail client in F# (31st March 2010) describes how you can write your own in just a few lines of F# code, centered around the following sequence expression:

> 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>


This is the library I used. It was very easy to use, didn't have any problems with it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜