|
'---------------------------------------------------------------------------------
'函数名称 : SendMail
'函数功能 : 自动发送邮件功能
'函数输入: SendTo----收件人,多个收件人可使用";"隔开
' MailTopic----邮件主题
' MailBody----邮件内容,此处内容格式为Html
' MailAttachment---邮件附件,多个附件可使用";"隔开
'函数输出: Boolean,邮件是否发送成功
'---------------------------------------------------------------------------------
Function SendMail(SendFrom,Password,SendTo,MailTopic,MailBody,MailAttachment)
'On error resume next
MS_Space = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
Email.BodyPart.Charset = "GBK"
Email.From = SendFrom
Email.To = SendTo
Email.Subject = MailTopic
Email.Htmlbody = MailBody
If MailAttachment <> "" Then
For i=0 to Ubound(Split(MailAttachment,";"))
Email.AddAttachment Split(MailAttachment,";")(i)
Next
End If
With Email.Configuration.Fields
.Item(MS_Space&"sendusing") = 2
.Item(MS_Space&"smtpserver") = "smtp."&Split(SendFrom,"@",-1, vbTextCompare)(1)
.Item(MS_Space&"smtpserverport") = 25
.Item(MS_Space&"smtpauthenticate") = 1
.Item(MS_Space&"sendusername") =Split(SendFrom,"@",-1,vbTextCompare)(0)
.Item(MS_Space&"sendpassword") = Password
.Update
End With
Err.clear
Email.Send
If Err.number<>0 Then
SendMail=False
Else
SendMail=True
End If
Set Email=Nothing
End Function
这个方法之前在xp系统下是可以使用的,但是装了win7系统后就不可以用了,应该是COM组件有的方法不支持,求能够发送邮件的方法,我是菜鸟,希望大家指教,非常感谢 |
|