vba实现内网自动发邮件
1. 如何实现把程序运行结果自动发送邮件
用我这个,根据发件邮箱,更改下面的服务器,原邮箱,目的邮箱,然后将程序快捷方式放在启动里就可实现开机运行,不要做非法的事
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