当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 定时检测邮件并且自动转发的例子

ASP.NET
ASP.NET入门教程:ArrayList对象
ASP.NET入门教程:Hashtable对象
ASP.NET入门教程:SortedList对象
ASP.NET入门教程:把XML文件绑定到列表控件
ASP.NET入门教程:Repeater控件
ASP.NET入门教程:DataList控件
ASP.NET入门教程:数据库连接
ASP.NET入门教程:ASP.NET 2.0新特性
ASP.NET入门教程:ASP.NET 2.0母版页
ASP.NET入门教程:ASP.NET 2.0导航
ASP.NET入门教程:HTML服务器控件
ASP.NET入门教程:Web服务器控件
ASP.NET入门教程:Validation服务器控件
HTML服务器控件介绍:HtmlAnchor控件
HTML服务器控件介绍:HtmlButton控件
HTML服务器控件介绍:HtmlForm控件
HTML服务器控件介绍:HtmlGeneric控件
HTML服务器控件介绍:HtmlImage控件
HTML服务器控件介绍:HtmlInputButton控件
HTML服务器控件介绍:HtmlInputCheckBox控件

ASP.NET 中的 定时检测邮件并且自动转发的例子


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 136 ::
收藏到网摘: n/a


我们在这里用的是一个dll控件,此控件的功能很强大,大家可以到http://www.hi-ho.ne.jp/babaq/eng/basp21.html下载并安装这个控件,下面我来讲一下具体的实现方法和代码
首先,我自己写了一个dll,调用下载的那个dll,提供了几个接口,可以填入发送人和接受人等等信息,此控件代码如下:
Imports BASP21Lib
Imports System.IO
Imports System.io.Directory
Public Shared Sub send(ByVal sendadd As String, ByVal resvAdd As String, ByVal subject As String, ByVal content As String)
Dim basptest As New BASP21Lib.Basp21
basptest.SendMail("192.168.1.19", sendadd, resvAdd, subject, content, "")
End Sub
Public Shared Sub checkmail(ByVal tesadd As String, ByVal password As String)
Dim basptest As New BASP21Lib.Basp21
Dim test As String
Dim resvAdd As String
Dim arrFile As Object
Dim eachF As Object
Dim strMailInfo As String
Dim strLast As Object
Dim thePath As String
Dim mes As Object
Dim message As String
thePath = GetCurrentDirectory() & CStr("\Mail")

strMailInfo = "from:to:X-to:Cc:X-Cc:Bcc:subject:Date:MIME-Version: " & "Content-Type:X-Priority:X-MSMail-Priority:X-Mailer:X-MimeOLE:"
arrFile = basptest.RcvMail("192.168.1.19", tesadd, password, "SAVEALLD", thePath)
If IsArray(arrFile) = False Then
Exit Sub
End If
For Each eachF In arrFile
strLast = basptest.ReadMail(eachF, strMailInfo, thePath)
For Each mes In strLast
message = message & mes & vbCrLf
Next mes
Next eachF
basptest.SendMail("192.168.1.19", "[email protected]", "[email protected]", "ddddd", "ddddddddddddd", "")
End Sub
End Class
然后我们利用系统服务来调用这个dll,代码如下:
Protected Overrides Sub OnStart(ByVal args() As String)
' サービスを開始するためのコードをここに追加します。このメソッドで、設定を行いながら
' サービスの実行が妨げられないようにします。
Dim timer1 As New Timer
timer1.Interval = 1000
timer1.Enabled = True
End Sub
Protected Overrides Sub OnStop()
' サービスを停止するのに必要な終了処理を実行するコードをここに追加します。
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
newmail.newmailclass.checkmail("[email protected]", "werwer")
End Sub
End Class
通过调用dll里的收邮件和发邮件函数自动实现邮件的转发,做成系统服务,调用这个dll,设置为自动启动,以后你的机器就多了一个功能(提供给有需要的用户)