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")
With Email
.From = "xxxx" '发件邮箱
.To = "xxxx" '收件邮箱
.Subject = "日报" '邮件主题
.TextBody = "日报内容" '邮件内容
' If Dir("C:\1.txt") <> "" Then
' .AddAttachment "C:\1.txt" '附件
' End If
With Email.Configuration.Fields
.Item(NameSpace & "sendusing") = 2
.Item(NameSpace & "smtpserver") = "smtp.mxhichina.com"
.Item(NameSpace & "smtpserverport") = 25 '端口,不要改!
.Item(NameSpace & "smtpauthenticate") = 1
.Item(NameSpace & "sendusername") = "reportsender@dynamik.cn" '邮箱用户名
.Item(NameSpace & "sendpassword") = "xxxx" '邮箱密码
.Update
End With
.Send
End With
If Err.Number <> 0 Then
MsgBox "无法发送邮件:" & Err.Description
Else
MsgBox "邮件发送成功", vbInformation
End If
Set Email = Nothing
End Sub
记几日报-vb6发送邮件并带附件
最新推荐文章于 2024-08-08 12:25:00 发布