【问题标题】:.Net POP3 client [duplicate].Net POP3 客户端 [重复]
【发布时间】:2011-03-10 03:47:37
【问题描述】:

.net 有一个用于发送邮件的 SMTP 客户端 但没有用于阅读邮件的 pop3 客户端。 我以前用过WEBDAV,但我真的想要一个简单的稳定的pop3或imap客户端

我知道似乎有 10000 个示例,但是如果他们制作了 SMTP 客户端,为什么没有官方 .net 客户端

有什么想法吗?

【问题讨论】:

标签: .net pop3


【解决方案1】:

The F#.NET Journal 文章 An e-mail client in F#(2010 年 3 月 31 日)描述了如何用几行 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>

【讨论】:

    【解决方案2】:

    This 是我使用的库。它非常易于使用,没有任何问题。

    【讨论】:

      猜你喜欢
      • 2010-12-10
      • 2018-03-02
      • 2011-05-11
      • 2011-01-11
      • 2015-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-28
      相关资源
      最近更新 更多