VB发送邮件源码,亲测可用
- 点滴记录
- 2021-02-24
- 4372
'Option ExplicitPrivate Sub Form_Load( Dim NameSpace As StringDim Email As Objec...
'Option Explicit
Private Sub Form_Load()
Dim NameSpace As String
Dim Email As Object
NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
Text1 = "有人送检啦,快回来检验吧!!" '邮件的内容
With Email
.From = "*************" '发件邮箱(此时要改为正确的发件邮箱)
.To = "*************" '收件邮箱(此时要改为正确的收件邮箱)
.Subject = "有待检件生成,请查看" '邮件主题
.TextBody = Text1 '邮件内容
With Email.Configuration.Fields
.Item(NameSpace & "sendusing") = 2
.Item(NameSpace & "smtpserver") = "smtp.163.com"
.Item(NameSpace & "smtpserverport") = 25 '端口,不要改!
.Item(NameSpace & "smtpauthenticate") = 1
.Item(NameSpace & "sendusername") = "*************" '邮箱用户名(此时要改为正确的发件邮箱)
.Item(NameSpace & "sendpassword") = "*************" '邮箱密码(此处写正确密码)
.Update
End With
.Send
End With
If Err.Number <> 0 Then
MsgBox "无法发送邮件:" & Err.Description
Else
MsgBox "邮件发送成功", vbInformation
End If
Set Email = Nothing
End Sub
借鉴:此地址点击可进入
本文链接:http://zxmcloud.com/?id=36
下一篇:阿里云盘公测啦,快领免费空间
发表评论