当前位置: 网学 > 编程文档 > VB > 正文

用VB实现一个简单的ESMTP客户端

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式
Text2.Text))
End Sub

Private Sub Command2_Click()
    state = 0
    smtpClient.Close
    smtpClient.Connect
End Sub

Private Sub Form_Load()
    mailcount = 2
    FLAG_LINE_END = Chr(13) + Chr(10)
    FLAG_MAIL_END = FLAG_LINE_END + "." + FLAG_LINE_END
End Sub

Private Sub Form_Terminate()
    smtpClient.Close
End Sub

Private Sub smtpClient_Close()
    ''MsgBox "closed!"
    state = 0
End Sub

Private Sub smtpClient_DataArrival(ByVal bytesTotal As Long)
    Dim s As String
    smtpClient.GetData s
    Text1.Text = Text1.Text + s + FLAG_LINE_END
    Dim msgHead As String
    msgHead = Left(s, 3)
    Dim msgBody As String
    msgBody = Mid(s, 5)
    
    Dim msgType As Integer
    msgType = CInt(msgHead)
    Dim msgsend As String
    
    Select Case state
    Case 0  ''start state
        Select Case msgType
        Case 220
            msgsend = "EHLO yourname" + FLAG_LINE_END
            smtpClient.SendData msgsend
            Text1.Text = Text1.Text + msgsend + FLAG_LINE_END
            state = 1
        Case 421    ''Service not available
        End Select
    Case 1  ''EHLO
        Select Case msgType
        Case 250
            msgsend = "AUTH LOGIN" + FLAG_LINE_END
            smtpClient.SendData msgsend
            Text1.Text = Text1.Text + msgsend + FLAG_LINE_END
            state = 2
        Case 500, 501, 504, 421 ''error happened
        End Select
    Case 2  ''AUTH LOGIN
        Select Case msgType
        Case 334
            If msgBody = "VXNlcm5hbWU6" + FLAG_LINE_END Then
&nb
  • 下一篇资讯: VB与数据连接的心得
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号