继克仔修改了我的RssReader后,添加了的用mail发送文章的功能!

修改后的源代码下载:
https://files.cnblogs.com/aowind/RssReader2.rar

主要添加了一个mail.vb的窗体:
源代码如下:
Imports System.web.mail

Public Class mail
    
Inherits System.Windows.Forms.Form

#Region 
" Windows 窗体设计器生成的代码 "

    Public Sub New()
        
MyBase.New()

        
'该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        
'在 InitializeComponent() 调用之后添加任何初始化

    
End Sub


    
'窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        
If disposing Then
            
If Not (components Is NothingThen
                components.Dispose()
            
End If
        
End If
        
MyBase.Dispose(disposing)
    
End Sub


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

    
'注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents Label1 As System.Windows.Forms.Label
    
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    
Friend WithEvents Label2 As System.Windows.Forms.Label
    
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    
Friend WithEvents Label3 As System.Windows.Forms.Label
    
Friend WithEvents Label4 As System.Windows.Forms.Label
    
Friend WithEvents Label5 As System.Windows.Forms.Label
    
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
    
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
    
Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
    
Friend WithEvents Button1 As System.Windows.Forms.Button
    
Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
    
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
    
Friend WithEvents Label6 As System.Windows.Forms.Label
    
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 
= New System.Windows.Forms.Label
        Me.TextBox1 
= New System.Windows.Forms.TextBox
        Me.Label2 
= New System.Windows.Forms.Label
        Me.TextBox2 
= New System.Windows.Forms.TextBox
        Me.GroupBox1 
= New System.Windows.Forms.GroupBox
        Me.Label3 
= New System.Windows.Forms.Label
        Me.Label4 
= New System.Windows.Forms.Label
        Me.Label5 
= New System.Windows.Forms.Label
        Me.TextBox3 
= New System.Windows.Forms.TextBox
        Me.TextBox4 
= New System.Windows.Forms.TextBox
        Me.TextBox5 
= New System.Windows.Forms.TextBox
        Me.CheckBox1 
= New System.Windows.Forms.CheckBox
        Me.Button1 
= New System.Windows.Forms.Button
        Me.StatusBar1 
= New System.Windows.Forms.StatusBar
        Me.TextBox6 
= New System.Windows.Forms.TextBox
        Me.Label6 
= New System.Windows.Forms.Label
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        
'
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("宋体"9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134Byte))
        Me.Label1.Location 
= New System.Drawing.Point(816)
        Me.Label1.Name 
= "Label1"
        Me.Label1.Size = New System.Drawing.Size(5624)
        Me.Label1.TabIndex 
= 0
        Me.Label1.Text 
= "收件人:"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(8016)
        Me.TextBox1.Name 
= "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(27221)
        Me.TextBox1.TabIndex 
= 1
        Me.TextBox1.Text 
= ""
        '
        'Label2
        '
        Me.Label2.Font = New System.Drawing.Font("宋体"9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134Byte))
        Me.Label2.Location 
= New System.Drawing.Point(880)
        Me.Label2.Name 
= "Label2"
        Me.Label2.Size = New System.Drawing.Size(5624)
        Me.Label2.TabIndex 
= 2
        Me.Label2.Text 
= "发信人:"
        '
        'TextBox2
        '
        Me.TextBox2.Location = New System.Drawing.Point(8080)
        Me.TextBox2.Name 
= "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(27221)
        Me.TextBox2.TabIndex 
= 3
        Me.TextBox2.Text 
= ""
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.CheckBox1)
        Me.GroupBox1.Controls.Add(Me.TextBox5)
        Me.GroupBox1.Controls.Add(Me.TextBox4)
        Me.GroupBox1.Controls.Add(Me.TextBox3)
        Me.GroupBox1.Controls.Add(Me.Label5)
        Me.GroupBox1.Controls.Add(Me.Label4)
        Me.GroupBox1.Controls.Add(Me.Label3)
        Me.GroupBox1.Font 
= New System.Drawing.Font("宋体"9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134Byte))
        Me.GroupBox1.Location 
= New System.Drawing.Point(8120)
        Me.GroupBox1.Name 
= "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(344128)
        Me.GroupBox1.TabIndex 
= 4
        Me.GroupBox1.TabStop 
= False
        Me.GroupBox1.Text 
= "SMTP服务器设置"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(1624)
        Me.Label3.Name 
= "Label3"
        Me.Label3.Size = New System.Drawing.Size(9616)
        Me.Label3.TabIndex 
= 0
        Me.Label3.Text 
= "SMTP服务器:"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(1672)
        Me.Label4.Name 
= "Label4"
        Me.Label4.Size = New System.Drawing.Size(9616)
        Me.Label4.TabIndex 
= 1
        Me.Label4.Text 
= "账号:"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(1696)
        Me.Label5.Name 
= "Label5"
        Me.Label5.Size = New System.Drawing.Size(9616)
        Me.Label5.TabIndex 
= 2
        Me.Label5.Text 
= "密码:"
        '
        'TextBox3
        '
        Me.TextBox3.Location = New System.Drawing.Point(9624)
        Me.TextBox3.Name 
= "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(24021)
        Me.TextBox3.TabIndex 
= 3
        Me.TextBox3.Text 
= ""
        '
        'TextBox4
        '
        Me.TextBox4.Location = New System.Drawing.Point(9672)
        Me.TextBox4.Name 
= "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(16821)
        Me.TextBox4.TabIndex 
= 4
        Me.TextBox4.Text 
= ""
        '
        'TextBox5
        '
        Me.TextBox5.Location = New System.Drawing.Point(9696)
        Me.TextBox5.Name 
= "TextBox5"
        Me.TextBox5.Size = New System.Drawing.Size(16821)
        Me.TextBox5.TabIndex 
= 5
        Me.TextBox5.Text 
= ""
        '
        'CheckBox1
        '
        Me.CheckBox1.Location = New System.Drawing.Point(2448)
        Me.CheckBox1.Name 
= "CheckBox1"
        Me.CheckBox1.Size = New System.Drawing.Size(20824)
        Me.CheckBox1.TabIndex 
= 6
        Me.CheckBox1.Text 
= "需要身份验证"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(216248)
        Me.Button1.Name 
= "Button1"
        Me.Button1.Size = New System.Drawing.Size(12832)
        Me.Button1.TabIndex 
= 5
        Me.Button1.Text 
= "发送"
        '
        'StatusBar1
        '
        Me.StatusBar1.Location = New System.Drawing.Point(0292)
        Me.StatusBar1.Name 
= "StatusBar1"
        Me.StatusBar1.Size = New System.Drawing.Size(36222)
        Me.StatusBar1.TabIndex 
= 6
        Me.StatusBar1.Text 
= "StatusBar1"
        '
        'TextBox6
        '
        Me.TextBox6.Location = New System.Drawing.Point(8048)
        Me.TextBox6.Name 
= "TextBox6"
        Me.TextBox6.Size = New System.Drawing.Size(27221)
        Me.TextBox6.TabIndex 
= 8
        Me.TextBox6.Text 
= ""
        '
        'Label6
        '
        Me.Label6.Font = New System.Drawing.Font("宋体"9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134Byte))
        Me.Label6.Location 
= New System.Drawing.Point(848)
        Me.Label6.Name 
= "Label6"
        Me.Label6.Size = New System.Drawing.Size(5624)
        Me.Label6.TabIndex 
= 7
        Me.Label6.Text 
= "标题:"
        '
        'mail
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(614)
        Me.ClientSize 
= New System.Drawing.Size(362314)
        Me.Controls.Add(Me.TextBox6)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.StatusBar1)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle 
= System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Name 
= "mail"
        Me.Text = "SendMail"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(
False)

    
End Sub


#
End Region
    
Public mail As New MailMessage
    
Public body As String
    
Public Sub stand(ByVal sbody As StringByVal title As String)
        TextBox6.Text 
= title
        body 
= Replace(sbody, "UTF-8""gb2312")
    
End Sub

    
Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click
        
With mail
            .
To = TextBox1.Text
            .From 
= TextBox2.Text
            .Subject 
= TextBox6.Text
            .Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate""1")
            .Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendusername", TextBox4.Text)
            .Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendpassword", TextBox5.Text)
            .BodyFormat 
= MailFormat.Html
            .Body 
= body
        
End With
        SmtpMail.SmtpServer 
= TextBox3.Text
        SmtpMail.Send(mail)
        
MsgBox("发送成功")
        
    
End Sub

End Class


在菜单内加入“发送文章给朋友”选项,name=FileSendMail, enabled=false
在loadhtml()过程里加上
FileSendMail.Enabled = True

再在主窗体上加上下面事件处理过程
 Private Sub FileSendMail_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles FileSendMail.Click
        
Dim smail As New mail
        smail.stand(cbii.TopicContents, cbii.TopicTitle)
        smail.ShowDialog()

    
End Sub

唉!下午公司网络出了问题,去买了一个MODEM,带路由功能,用起来还没有原来的不带路由功能的好用!
浪费了一下午时间,这个功能也就勿勿而就
posted @ 2005-03-23 17:37  Aowind  阅读(1298)  评论(6)    收藏  举报