利用OpenPOP开源组件实现接收电子邮件功能

时间:2022-03-16 11:15:30

网上关于接收电子邮件的代码很多,试用后,能满足要求的甚少。OpenPop(http://sourceforge.net/projects/hpop/)现在有了新的版本,且能经过VS2010编译,值得使用。可惜的是我现在对C#不熟悉,其demo经研究后转成VB.net实现。


OpenPOP的test截图:


利用OpenPOP开源组件实现接收电子邮件功能

我自己做的实例:


利用OpenPOP开源组件实现接收电子邮件功能
以下是代码部分:


<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
_
Partial Class FetchEmail
Inherits
System.Windows.Forms.Form


'Form 重写 Dispose,以清理组件列表。

<System.Diagnostics.DebuggerNonUserCode()> _

Protected Overrides Sub Dispose(ByVal disposing As
Boolean)

Try
If
disposing AndAlso components IsNot Nothing
Then

components.Dispose()

End If

Finally

MyBase.Dispose(disposing)
End
Try
End Sub


'Windows 窗体设计器所必需的
Private
components As System.ComponentModel.IContainer


'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用
Windows 窗体设计器修改它。
'不要使用代码编辑器修改它。

<System.Diagnostics.DebuggerStepThrough()> _
Private
Sub InitializeComponent()

Me.Label1 = New
System.Windows.Forms.Label()

Me.txtPOP3Server = New
System.Windows.Forms.TextBox()

Me.btnFetchEmail = New
System.Windows.Forms.Button()

Me.txtPort = New
System.Windows.Forms.TextBox()

Me.Label2 = New
System.Windows.Forms.Label()

Me.txtName = New
System.Windows.Forms.TextBox()

Me.Label3 = New
System.Windows.Forms.Label()

Me.txtPassword = New
System.Windows.Forms.TextBox()

Me.Label4 = New
System.Windows.Forms.Label()

Me.txtEmailCount = New
System.Windows.Forms.TextBox()

Me.Label5 = New
System.Windows.Forms.Label()

Me.txtRead = New
System.Windows.Forms.TextBox()

Me.Label6 = New
System.Windows.Forms.Label()

Me.txtBody = New
System.Windows.Forms.TextBox()

Me.txtFrom = New
System.Windows.Forms.TextBox()

Me.Label7 = New
System.Windows.Forms.Label()

Me.Label8 = New
System.Windows.Forms.Label()

Me.Label9 = New
System.Windows.Forms.Label()

Me.txtSubject = New
System.Windows.Forms.TextBox()

Me.Label10 = New
System.Windows.Forms.Label()

Me.lstAttachments = New
System.Windows.Forms.ListBox()

Me.btnConnectLogin = New
System.Windows.Forms.Button()

Me.TableLayoutPanel1 = New
System.Windows.Forms.TableLayoutPanel()

Me.TableLayoutPanel1.SuspendLayout()

Me.SuspendLayout()

'

'Label1

'
Me.Label1.AutoSize =
True
Me.Label1.Dock =
System.Windows.Forms.DockStyle.Right

Me.Label1.Location = New System.Drawing.Point(13,
10)
Me.Label1.Name =
"Label1"
Me.Label1.Size = New
System.Drawing.Size(99, 35)