1个回答
展开全部
On Error Goto ErrInfo Dim Email As Object Const NameSpace = " http://schemas.microsoft.com/cdo/configuration/" Set Email = CreateObject("CDO.Message") Email.From = "test@126.com" '你的邮箱地址 Email.To = "test2@126.com" '要发往的地址 Email.Subject = "你好这是测试" '主题 Email.Textbody = "这只是一个测试" '正文 Email.AddAttachment "E:\Test.txt" '附件,可以添加多个 Email.AddAttachment "D:\Test.EXE" With Email.Configuration.Fields .Item(NameSpace & "sendusing") = 2 .Item(NameSpace & "smtpserver") = "smtp.126.com" '发送邮件服务器 .Item(NameSpace & "smtpserverport") = 25 .Item(NameSpace & "smtpauthenticate") = 1 .Item(NameSpace & "sendusername") = "test" '邮箱用户名 .Item(NameSpace & "sendpassword") = "******" '密码 .Update End With Email.Send MsgBox "发送成功" Exit Sub ErrInfo: Msgbox "发送失败!"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询