不用写了,买个webeasymail就搞定了,不是很贵----------------------------------------------------------------------
欢迎试用ASP.NET大文件上传组件(AspnetUpload 1.0 Release & 无刷新进度条)
http://bestcomy.europe.webmatrixhosting.net
----------------------------------------------------------------------

解决方案 »

  1.   

    我用 vb.net 写的  你可以 看看 又没有用:'使用pop3协议接收邮件
    Imports System.Net
    Imports System.IO
    Imports System.Net.SocketsPublic Class Form1
        Inherits System.Windows.Forms.Form#Region " Windows 窗体设计器生成的代码 "    Public Sub New()
            MyBase.New()        '该调用是 Windows 窗体设计器所必需的。
            InitializeComponent()        '在 InitializeComponent() 调用之后添加任何初始化    End Sub    '窗体重写处置以清理组件列表。
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub    'Windows 窗体设计器所必需的
        Private components As System.ComponentModel.IContainer    '注意:以下过程是 Windows 窗体设计器所必需的
        '可以使用 Windows 窗体设计器修改此过程。
        '不要使用代码编辑器修改它。
        Friend WithEvents Button1 As System.Windows.Forms.Button
        Friend WithEvents txtServer As System.Windows.Forms.TextBox
        Friend WithEvents Label1 As System.Windows.Forms.Label
        Friend WithEvents txtUsername As System.Windows.Forms.TextBox
        Friend WithEvents Label2 As System.Windows.Forms.Label
        Friend WithEvents txtPassword As System.Windows.Forms.TextBox
        Friend WithEvents Label3 As System.Windows.Forms.Label
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.Button1 = New System.Windows.Forms.Button
            Me.txtServer = New System.Windows.Forms.TextBox
            Me.Label1 = New System.Windows.Forms.Label
            Me.txtUsername = New System.Windows.Forms.TextBox
            Me.Label2 = New System.Windows.Forms.Label
            Me.txtPassword = New System.Windows.Forms.TextBox
            Me.Label3 = New System.Windows.Forms.Label
            Me.SuspendLayout()
            '
            'Button1
            '
            Me.Button1.Location = New System.Drawing.Point(264, 16)
            Me.Button1.Name = "Button1"
            Me.Button1.TabIndex = 0
            Me.Button1.Text = "检查邮件"
            '
            'txtServer
            '
            Me.txtServer.Location = New System.Drawing.Point(64, 8)
            Me.txtServer.Name = "txtServer"
            Me.txtServer.Size = New System.Drawing.Size(176, 21)
            Me.txtServer.TabIndex = 1
            Me.txtServer.Text = ""
            '
            'Label1
            '
            Me.Label1.Location = New System.Drawing.Point(8, 8)
            Me.Label1.Name = "Label1"
            Me.Label1.TabIndex = 2
            Me.Label1.Text = "服务器:"
            '
            'txtUsername
            '
            Me.txtUsername.Location = New System.Drawing.Point(64, 40)
            Me.txtUsername.Name = "txtUsername"
            Me.txtUsername.Size = New System.Drawing.Size(176, 21)
            Me.txtUsername.TabIndex = 3
            Me.txtUsername.Text = ""
            '
            'Label2
            '
            Me.Label2.Location = New System.Drawing.Point(8, 40)
            Me.Label2.Name = "Label2"
            Me.Label2.TabIndex = 4
            Me.Label2.Text = "用户名:"
            '
            'txtPassword
            '
            Me.txtPassword.Location = New System.Drawing.Point(64, 72)
            Me.txtPassword.Name = "txtPassword"
            Me.txtPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
            Me.txtPassword.Size = New System.Drawing.Size(176, 21)
            Me.txtPassword.TabIndex = 5
            Me.txtPassword.Text = ""
            '
            'Label3
            '
            Me.Label3.Location = New System.Drawing.Point(8, 72)
            Me.Label3.Name = "Label3"
            Me.Label3.TabIndex = 6
            Me.Label3.Text = "密码:"
            '
            'Form1
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
            Me.ClientSize = New System.Drawing.Size(344, 109)
            Me.Controls.Add(Me.txtPassword)
            Me.Controls.Add(Me.Label3)
            Me.Controls.Add(Me.txtUsername)
            Me.Controls.Add(Me.Label2)
            Me.Controls.Add(Me.txtServer)
            Me.Controls.Add(Me.Label1)
            Me.Controls.Add(Me.Button1)
            Me.Name = "Form1"
            Me.Text = "POP3 Demo"
            Me.ResumeLayout(False)    End Sub#End Region    Private Function Connect() As NetworkStream
            Dim sender As New TcpClient(txtServer.Text, 110)
            Dim outbytes As Byte()
            Dim input As String
            Dim ns As NetworkStream = Nothing
            Try
                ns = sender.GetStream()
                Dim sr = New StreamReader(ns)
                Console.WriteLine(sr.ReadLine())            input = "user " + txtUsername.Text + vbCrLf
                outbytes = System.Text.Encoding.ASCII.GetBytes(input.ToCharArray())
                ns.Write(outbytes, 0, outbytes.Length)
                Console.WriteLine(sr.ReadLine())            input = "pass " + txtPassword.Text + vbCrLf
                outbytes = System.Text.Encoding.ASCII.GetBytes(input.ToCharArray())
                ns.Write(outbytes, 0, outbytes.Length)
                Console.WriteLine(sr.ReadLine())            Return ns
            Catch ioe As InvalidOperationException
                MsgBox("无法连接到服务器", MsgBoxStyle.Critical)
                Return ns
            End Try
        End Function    Private Function GetNumberOfNewMessages() As Integer
            Dim outbytes As Byte()
            Dim input As String
            Try
                Dim ns As NetworkStream = Connect()
                Dim sr = New StreamReader(ns)            input = "stat" + vbCrLf
                outbytes = System.Text.Encoding.ASCII.GetBytes(input.ToCharArray())
                ns.Write(outbytes, 0, outbytes.Length)
                Dim resp As String = sr.ReadLine()
                Console.WriteLine(resp)
                Dim tokens As String() = resp.Split(" ")            input = "quit" + vbCrLf
                outbytes = System.Text.Encoding.ASCII.GetBytes(input.ToCharArray())
                ns.Write(outbytes, 0, outbytes.Length)
                Console.WriteLine(sr.ReadLine())            sr.Close()
                ns.Close()
                Return Val(tokens(1))
            Catch ioe As InvalidOperationException
                MsgBox("无法连接到服务器", MsgBoxStyle.Critical)
                Return 0
            End Try
        End Function    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            MsgBox("邮件数:" & GetNumberOfNewMessages())
        End Sub    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load    End Sub
    End Class
      

  2.   

    '这个是 使用 SMTP 协议发送电子邮件
    Imports System.Web.MailPublic Class Form1
        Inherits System.Windows.Forms.Form#Region " Windows 窗体设计器生成的代码 "    Public Sub New()
            MyBase.New()        '该调用是 Windows 窗体设计器所必需的。
            InitializeComponent()        '在 InitializeComponent() 调用之后添加任何初始化    End Sub    '窗体重写处置以清理组件列表。
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub    'Windows 窗体设计器所必需的
        Private components As System.ComponentModel.IContainer    '注意:以下过程是 Windows 窗体设计器所必需的
        '可以使用 Windows 窗体设计器修改此过程。
        '不要使用代码编辑器修改它。
        Friend WithEvents Label3 As System.Windows.Forms.Label
        Friend WithEvents Label2 As System.Windows.Forms.Label
        Friend WithEvents txtServer As System.Windows.Forms.TextBox
        Friend WithEvents Label1 As System.Windows.Forms.Label
        Friend WithEvents Button1 As System.Windows.Forms.Button
        Friend WithEvents txtMsg As System.Windows.Forms.TextBox
        Friend WithEvents txtTo As System.Windows.Forms.TextBox
        Friend WithEvents txtFrom As System.Windows.Forms.TextBox
        Friend WithEvents txtAttachment As System.Windows.Forms.TextBox
        Friend WithEvents Label4 As System.Windows.Forms.Label
        Friend WithEvents txtSubject As System.Windows.Forms.TextBox
        Friend WithEvents Label5 As System.Windows.Forms.Label
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.txtTo = New System.Windows.Forms.TextBox
            Me.Label3 = New System.Windows.Forms.Label
            Me.txtFrom = New System.Windows.Forms.TextBox
            Me.Label2 = New System.Windows.Forms.Label
            Me.txtServer = New System.Windows.Forms.TextBox
            Me.Label1 = New System.Windows.Forms.Label
            Me.Button1 = New System.Windows.Forms.Button
            Me.txtMsg = New System.Windows.Forms.TextBox
            Me.txtAttachment = New System.Windows.Forms.TextBox
            Me.Label4 = New System.Windows.Forms.Label
            Me.txtSubject = New System.Windows.Forms.TextBox
            Me.Label5 = New System.Windows.Forms.Label
            Me.SuspendLayout()
            '
            'txtTo
            '
            Me.txtTo.Location = New System.Drawing.Point(64, 64)
            Me.txtTo.Name = "txtTo"
            Me.txtTo.Size = New System.Drawing.Size(176, 21)
            Me.txtTo.TabIndex = 5
            Me.txtTo.Text = ""
            '
            'Label3
            '
            Me.Label3.Location = New System.Drawing.Point(8, 64)
            Me.Label3.Name = "Label3"
            Me.Label3.TabIndex = 4
            Me.Label3.Text = "收信人:"
            '
            'txtFrom
            '
            Me.txtFrom.Location = New System.Drawing.Point(64, 40)
            Me.txtFrom.Name = "txtFrom"
            Me.txtFrom.Size = New System.Drawing.Size(176, 21)
            Me.txtFrom.TabIndex = 3
            Me.txtFrom.Text = ""
            '
            'Label2
            '
            Me.Label2.Location = New System.Drawing.Point(8, 40)
            Me.Label2.Name = "Label2"
            Me.Label2.TabIndex = 2
            Me.Label2.Text = "发信人:"
            '
            'txtServer
            '
            Me.txtServer.Location = New System.Drawing.Point(64, 16)
            Me.txtServer.Name = "txtServer"
            Me.txtServer.Size = New System.Drawing.Size(176, 21)
            Me.txtServer.TabIndex = 1
            Me.txtServer.Text = ""
            '
            'Label1
            '
            Me.Label1.Location = New System.Drawing.Point(8, 16)
            Me.Label1.Name = "Label1"
            Me.Label1.TabIndex = 0
            Me.Label1.Text = "服务器:"
            '
            'Button1
            '
            Me.Button1.Location = New System.Drawing.Point(264, 24)
            Me.Button1.Name = "Button1"
            Me.Button1.TabIndex = 11
            Me.Button1.Text = "发送邮件"
            '
            'txtMsg
            '
            Me.txtMsg.Location = New System.Drawing.Point(8, 144)
            Me.txtMsg.Multiline = True
            Me.txtMsg.Name = "txtMsg"
            Me.txtMsg.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
            Me.txtMsg.Size = New System.Drawing.Size(336, 160)
            Me.txtMsg.TabIndex = 10
            Me.txtMsg.Text = ""
            '
            'txtAttachment
            '
            Me.txtAttachment.Location = New System.Drawing.Point(64, 112)
            Me.txtAttachment.Name = "txtAttachment"
            Me.txtAttachment.Size = New System.Drawing.Size(176, 21)
            Me.txtAttachment.TabIndex = 9
            Me.txtAttachment.Text = ""
            '
            'Label4
            '
            Me.Label4.Location = New System.Drawing.Point(8, 112)
            Me.Label4.Name = "Label4"
            Me.Label4.TabIndex = 8
            Me.Label4.Text = "附件:"
            '
            'txtSubject
            '
            Me.txtSubject.Location = New System.Drawing.Point(64, 88)
            Me.txtSubject.Name = "txtSubject"
            Me.txtSubject.Size = New System.Drawing.Size(176, 21)
            Me.txtSubject.TabIndex = 7
            Me.txtSubject.Text = ""
            '
            'Label5
            '
            Me.Label5.Location = New System.Drawing.Point(8, 88)
            Me.Label5.Name = "Label5"
            Me.Label5.TabIndex = 6
            Me.Label5.Text = "标题:"
            '
            'Form1
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
            Me.ClientSize = New System.Drawing.Size(352, 309)
            Me.Controls.Add(Me.txtAttachment)
            Me.Controls.Add(Me.Label4)
            Me.Controls.Add(Me.txtSubject)
            Me.Controls.Add(Me.Label5)
            Me.Controls.Add(Me.txtMsg)
            Me.Controls.Add(Me.txtTo)
            Me.Controls.Add(Me.Label3)
            Me.Controls.Add(Me.txtFrom)
            Me.Controls.Add(Me.Label2)
            Me.Controls.Add(Me.txtServer)
            Me.Controls.Add(Me.Label1)
            Me.Controls.Add(Me.Button1)
            Me.Name = "Form1"
            Me.Text = "SmtpMail Demo"
            Me.ResumeLayout(False)    End Sub#End Region    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim mailmsg As New MailMessage()        If txtServer.Text <> "" Then
                SmtpMail.SmtpServer = txtServer.Text
            End If
            mailmsg.From = txtFrom.Text
            mailmsg.To = txtTo.Text
            mailmsg.Priority = MailPriority.High
            If txtAttachment.Text <> "" Then
                mailmsg.Attachments.Add(New MailAttachment(txtAttachment.Text))
            End If
            mailmsg.Subject = txtSubject.Text
            mailmsg.BodyFormat = MailFormat.Html
            mailmsg.Body = txtMsg.Text
            SmtpMail.Send(mailmsg)
            MsgBox("发送完成!")
        End Sub    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load    End Sub
    End Class
      

  3.   

    不用花钱找一个开源的就OK了!给你提供一个网址:http://www.lumisoft.ee/lsWWW/ENG/Products/Mail_Server/mail_index_eng.aspx?type=info