VB使用CDO的方式发送邮件的源代码
Sub CDOSendEmail()
Dim objEmail As Object
Dim strName As String
strName = "http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
objEmail.BodyPart.Charset = "gb2312"
objEmail.From = "testmail@163.com"
objEmail.To = "testmail@163.com"
objEmail.Subject = "测试发送标题"
objEmail.Textbody = "测试发送内容"
objEmail.Configuration.Fields.Item(strName & "sendusing") = 2
objEmail.Configuration.Fields.Item(strName & "smtpserver") = "smtp.163.com"
objEmail.Configuration.Fields.Item(strName & "smtpserverport") = 25
objEmail.Configuration.Fields.Item(strName & "smtpauthenticate") = 1
objEmail.Configuration.Fields.Item(strName & "sendusername") = "username"
objEmail.Configuration.Fields.Item(strName & "sendpassword") = "mima"
objEmail.Configuration.Fields.Update
objEmail.Send
End Sub
注意:现在163等一些邮箱默认关闭了POP3、STMP、Exchange协议。请打开,并且注意用的不是原先邮箱登陆密码,而是单独设置的独立密码。