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

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

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

Private Sub Send(from As String, to1 As String, subject As String, ctype As String, content As String)
    Dim msgsend As String
    msgsend = "From: " + from + FLAG_LINE_END
    msgsend = msgsend + "To: " + to1 + FLAG_LINE_END
    msgsend = msgsend + "Subject: " + subject + FLAG_LINE_END
    msgsend = msgsend + "Date: " + CStr(Now) + FLAG_LINE_END
    msgsend = msgsend + "MIME-Version: 1.0" + FLAG_LINE_END
    msgsend = msgsend + "Content-Type: text/" + ctype + ";charset=gb2312" + FLAG_LINE_END
    ''msgSend = msgSend + "Content-Transfer-Encoding: base64" + flag_line_end
    msgsend = msgsend + content + FLAG_LINE_END
    smtpClient.SendData msgsend
    smtpClient.SendData FLAG_MAIL_END
End Sub
Private Sub SetFrom(from As String)
    msgsend = "MAIL FROM: <" + from + ">" + FLAG_LINE_END
    smtpClient.SendData msgsend
    Text1.Text = Text1.Text + msgsend + FLAG_LINE_END
End Sub
Private Sub SetRcpt(rcpt As String)
    Dim msgsend As String
    
    msgsend = "RCPT TO: <" + rcpt + ">" + FLAG_LINE_END
    smtpClient.SendData msgsend
    Text1.Text = Text1.Text + msgsend + FLAG_LINE_END
End Sub

Private Sub smtpClient_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    MsgBox Description
End Sub


2 func.bas

Attribute VB_Name = "Module1"
Private base64EncodeChars As String
Private base64DecodeChars(127) As Integer


Function base64encode(str As String) As String
    base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
    
    Dim out, i, len1
    Dim c1, c2, c3
    len1 = Len(str)
    i = 0
    out = ""
    
    While i < len1
        c1 = Asc(Mid(str, i + 1, 1))
        i = i + 1
    
        If (i = len1) Then
            out = out + Mid(base64EncodeChars, c1 \ 4 + 1, 1)
            out = out + Mid(base64EncodeChars, (c1 And 3) * 16 + 1, 1)
&n
  • 下一篇资讯: VB与数据连接的心得
  • 网学推荐

    免费论文

    原创论文

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