不用写了,买个webeasymail就搞定了,不是很贵----------------------------------------------------------------------
欢迎试用ASP.NET大文件上传组件(AspnetUpload 1.0 Release & 无刷新进度条)
http://bestcomy.europe.webmatrixhosting.net
----------------------------------------------------------------------
欢迎试用ASP.NET大文件上传组件(AspnetUpload 1.0 Release & 无刷新进度条)
http://bestcomy.europe.webmatrixhosting.net
----------------------------------------------------------------------
解决方案 »
- 请问正则表达式大小写的问题
- 哪个软件安装制作工具可以在安装我自己的Winform程序的同时,还可以安装framework。
- vs.net 2003调试的怪现象,郁闷啥事都有
- 在.NET中如何实现简单的审批....
- 用asp.net新建的网站,大家看看怎么样?
- 是什么病毒引起部分文件夹下的文件丢失,但文件夹还在,系统文件丢失后,系统就崩溃?你不知道了不要紧,告诉我一个好的反病毒网站也可
- Request的小问题!!!
- 去年的时候,微软发布了几个 web标准的 站点模板,供我们用Vs2005使用,搜索了一下,没有找到.
- 请教一下c#的asp.net如何实现登录验证的功能
- asp.net中Response.Write..........
- 100分求不够在加在ASP里面怎么查询数据库里面是否包含某个字段
- 如何绑定html服务器控件-table
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
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