VB发邮件代码

下面段代码是VB发邮件代码

Private Sub Form_Load()
On Error Resume Next
Dim NameSa As String
Dim Email As Object
NameSa = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
Email.From = "longyunaihui@163.com" '你的发邮件地址,比如xxx@sina.com
Email.To = " 610358898@qq.com" 'example@163.com
Email.Subject = "测试一下" '邮件的标题
Email.Textbody = "现代职业学院" '& 邮件正文&
Email.AddAttachment "" '附件的路径
Email.Configuration.Fields.Item(NameSa & "sendusing") = 2
Email.Configuration.Fields.Item(NameSa & "smtpserver") = "smtp.163.com" 'smtp.sina.com 这里填邮件的smtp服务器
Email.Configuration.Fields.Item(NameSa & "smtpserverport") = 25 '
Email.Configuration.Fields.Item(NameSa & "smtpauthenticate") = 1
Email.Configuration.Fields.Item(NameSa & "sendusername") = "longyunaihui@163.com" '你的邮箱用户名
Email.Configuration.Fields.Item(NameSa & "sendpassword") = "888888888" '你的邮箱密码
Email.Configuration.Fields.Update
Email.send
End Sub

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.