古詩詞大全網 - 四字成語 - vb自動後臺發送郵件

vb自動後臺發送郵件

On Error Goto ErrInfo Dim Email As Object Const NameSpace = " /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 "發送失敗!"