VBS通过SMTP发送邮件
2010-11-24 23:10
267 查看
mfrom="abcd@abcd.com" rcpt="abcd@abcd.com, abcd@abcd.com" attachfile=null serverip="smtp.abcd.com" sbj="Subject" tbody="Hello World" Call SendMail(mfrom,rcpt,sbj,tbody,attachfile,serverIP)
Sub SendMail (mfrom,rcpt,sbj,tbody,attachfile,serverIP) '######### call SendMail (mfrom,rcpt,cc,sbj,tbody,serverIP) ################## 'Use external smtp server to send mail if trim(rcpt) = "" or trim(mfrom) = "" then exit sub end if On Error Resume Next Set objEmail = CreateObject("CDO.Message") objEmail.From = mfrom objEmail.To = rcpt ' objEmail.Cc = cc ' objEmail.Bcc = bcc objEmail.Subject = sbj objEmail.Textbody = tbody 'Sending an HTML e-mail: ' objEmail.HTMLBody = " This is a message. " 'Sending an HTML e-mail that sends a webpage from a website: ' objEmail.CreateMHTMLBody "file://c:/mydocuments/test.htm" If Trim(attachfile) <> "" Then objEmail.AddAttachment attachfile objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = serverIP objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 '-------Type of authentication, NONE, Basic (Base64 encoded), NTLM-------- 'objEmail.Configuration.Fields.Item _ '("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic '-------Your UserID/Passwd on the SMTP server for SMTP auth for mail sent----- 'objEmail.Configuration.Fields.Item _ '("http://schemas.microsoft.com/cdo/configuration/sendusername") = "USER_NAME" 'objEmail.Configuration.Fields.Item _ '("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "PASSWORD" '-------Use SSL for the connection (False or True)--------- 'objEmail.Configuration.Fields.Item _ '("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Connection Timeout in seconds (the maximum time CDO will try to establish a '--------connection to the SMTP server)--------- 'objEmail.Configuration.Fields.Item _ '("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objEmail.Configuration.Fields.Update objEmail.Send set objEmail=nothing End Sub
相关文章推荐
- Centos下通过SMTP发送邮件失败解决
- smtplib 通过ssl端口发送邮件
- Delphi通过IdSmtp发送邮件的简单代码
- Perl 通过SMTP发送正文为HTML格式的邮件
- 通过SMTP中继服务器发送邮件的问题
- python(通过flask实现一个http接口)调用这个接口实现第三方smtp发送邮件
- powershell 通过SMTP发送邮件
- 使用PowerShell通过Smtp发送邮件
- 一个通过smtp发送邮件的shell,带用户名密码
- Oracle PLSQL通过SMTP发送E-MAIL邮件代码
- 用PHP通过SMTP发送邮件
- Python:通过SMTP服务器发送邮件
- 使用Pear和php socket来实现通过smtp验证发送邮件
- 使用System.Web.Mail 组件通过SMTP认证发送邮件
- 用newLISP通过SMTP服务器发送邮件
- PHP mail 通过Windows的SMTP发送邮件失败的解决方案
- java通过SMTP发送QQ邮件的完全步骤
- php中通过curl smtp发送邮件
- PHP通过SMTP实现发送邮件_包括附件
- 使用PowerShell通过Smtp发送邮件