1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
'--------------------------------------------------------------------------------- '函数名称 : SendMail '函数功能 : 自动发送邮件功能 '函数输入 : SendTo----收件人,多个收件人可使用";"隔开 ' MailTopic----邮件主题 ' MailBody----邮件内容,此处内容格式为Html ' MailAttachment---邮件附件,多个附件可使用";"隔开 '函数输出 : Boolean,邮件是否发送成功 '--------------------------------------------------------------------------------- Function SendMail(SendFrom,Password,SendTo,MailTopic,MailBody,MailAttachment)
On error resume next
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
|
相关文章
- 11-24Delphi发送邮件...
- 11-24自动祝福(定时发送消息)
- 11-24svn自动发用户名密码到邮件(明文密码)
- 11-24Python——SMTP发送邮件
- 11-24使用Python SMTP发送邮件
- 11-24python通过SMTP发送邮件失败,报错505/535
- 11-24python实现邮件发送完整代码(带附件发送方式)
- 11-24Jenkins配置QQ邮箱发送邮件
- 11-24利用smtp协议实现黑窗口发送邮件
- 11-24.net core 个人 smtp服务 邮件发送