我必须向申请人发送一封简单的邮件,以便成功提交表格.Vb中的代码是什么? 我一直在尝试这个..
function email()
Set mailObj=CreateObject("CDO.Message")
mailObj.Subject="Hello"
mailObj.From="abc@xyz.com"
mailObj.To="123@456.com"
mailObj.TextBody="text"
mailObj.Send
set mailObj=nothing
end function
代码中是否有问题?请纠正..
答案 0 :(得分:3)
使用以下内容。
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "fromsomeone@company.com"
objEmail.To = "someone@company.com"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"your.smtpserver.here"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.TextBody = "The body of the email"
objEmail.Subject = "The subject"
objEmail.Send