如何实现把程序运行结果自动发送邮件?
发布网友
发布时间:2022-05-05 00:41
我来回答
共1个回答
热心网友
时间:2022-04-18 09:04
用我这个,根据发件邮箱,更改下面的服务器,原邮箱,目的邮箱,然后将程序快捷方式放在启动里就可实现开机运行,不要做非法的事
Private Sub Form_Load()
Me.Visible = False
Dim objEmail As Object
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "原邮箱"
objEmail.To = "目的邮箱"
objEmail.Subject = "邮件标题"
objEmail.Textbody = "邮件正文 "
objEmail.AddAttachment App.Path & "\abc.ini" '附件内容,不要可删掉
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sensing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.163.com" '发信服务器,假设为163邮箱
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sensername") = " 发信的邮箱名"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "发信的邮箱密码"
objEmail.Configuration.Fields.Update
objEmail.Send
End Sub追问谢谢你的回复,感谢,我目前的情况是我用java实现了一个程序的自动化测试,我想自动化跑完,能自动化发邮件通知一些人自动化跑的结果