.......
Dim mailDR As OleDbDataReader
Dim strEmail, strSubject As String
Dim strSQLuser As String
Dim objcmdmail As OleDbCommand ' OLEDB提供者字符串
Dim objCon = New OleDbConnection(strDbCon)
objCon.Open() ' 打开数据库连接
strSQLuser = "SELECT user_name,user_email FROM esun_tbl_user "
' 建立Command对象的SQL命令
objcmdmail = New OleDbCommand(strSQLuser, objCon)
' 获取DataReader对象
mailDR = objcmdmail.ExecuteReader()
Dim objBcc As New MailAddressCollection
' 读取记录数据, 建立MailAddress对象
Do While mailDR.Read()
If mailDR.IsDBNull(mailDR. _
GetOrdinal( "User_Email ")) = False Then
strEmail = mailDR.Item( "User_Email ")
' 显示收件者的邮件地址
msg.Text &= "发送邮件到: <b> " & strEmail & " </b> <br> "
objBcc.Add(New MailAddress(strEmail))
End If
Loop
mailDR.Close() ' 关闭DataReader
objCon.Close() ' 关闭数据库连接
' 设置邮件的内容
strSubject = "Lynn test call mail "
' 使用副本密件发送大量邮件
sendEmail(objBcc, strSubject)
End Sub
' 发送电子邮件