TA的每日心情 | 奋斗 2014-12-18 10:31 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
下面代码是个通用方法
Public Function Sendmail(mailfrom,mailto,smtp,username,password,mailtitle,mailbody,attachment)
'参数说明:
'发件人:mailfrom 收件人:mailto 邮件发送服务器:smtp 发件人邮箱地址:username 发件人邮箱密码:password 邮件标题:mailtitle 邮件内容:mailbody 附件路径:attachment
NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = createObject("CDO.Message")
Email.From =mailfrom
Email.To = mailto
Email.Subject = mailtitle
Email.Textbody = mailbody
Email.AddAttachment attachment
With Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = smtp
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = username
.Item(NameSpace&"sendpassword") = password
.update
End With
Email.Send
End Function |
|