配置环境:.Net Framework 2.0 测试版2,w3Jmail4.4,Windows XP (sp2)
使用过程:
1.首先安装jmail4.4
2.找到jmail.dll(安装目录下)copy 到D:/Microsoft Visual Studio 8/SDK/v2.0/Bin 目录下
3.假设你把Visual Basic 2005 安装在 D:/Microsoft Visual Studio 8 底下;
在命令行提示符状态下进入D:/Microsoft Visual Studio 8/SDK/v2.0/Bin 目录;
执行 tlbimp c:/Program Files/Dimac/w3JMail4/jmail.dll /out:VBJmail.dll /namespace:VBJmail
生成VBJmail.dll后,copy到你编写的应用程序的bin目录里。(这一步必需的,否则你编写的程序将无法正常运行)
4.在VB2005里新建一个工程,并添加对VBJmail的引用;
在窗体上添加一个用来发送邮件的按钮;
代码示例如下:
Public Class Form1 Class Form1
Dim msg As New VBJmail.Message ' 实例化VBJmail
Private Sub Button1_Click() Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Biaoti , Neirong As String
Biaoti = " 试验 "
Neirong = " 你好这是一个试验 "
msg.From = " lgx1972@gmail.com " ' 邮件发送方
msg.Charset = " GB2312 " ' 邮件编码
msg.FromName = " 李国雄 " ' 发送人姓名
msg.AddRecipient( " lgx1972@163.com " ) ' 邮件接收方
msg.Subject = Biaoti ' 添加邮件的标题
msg.Body = Neirong ' 添加邮件的内容
msg.Send( " LGX1972:******@smtp.gmail.com " ) ' 括号里的是(发送方的用户名:密码@邮件服务器名)
msg.Close()
End Sub
Dim msg As New VBJmail.Message ' 实例化VBJmail
Private Sub Button1_Click() Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Biaoti , Neirong As String
Biaoti = " 试验 "
Neirong = " 你好这是一个试验 "
msg.From = " lgx1972@gmail.com " ' 邮件发送方
msg.Charset = " GB2312 " ' 邮件编码
msg.FromName = " 李国雄 " ' 发送人姓名
msg.AddRecipient( " lgx1972@163.com " ) ' 邮件接收方
msg.Subject = Biaoti ' 添加邮件的标题
msg.Body = Neirong ' 添加邮件的内容
msg.Send( " LGX1972:******@smtp.gmail.com " ) ' 括号里的是(发送方的用户名:密码@邮件服务器名)
msg.Close()
End Sub