VBS 发送邮件

简爱代码2013-1-28 13:1061933
利用VBS发送 邮件 方便 BAT 调用
'  SendMail.vbs  By 简爱 http://www.gouji.org
qq = "418682275"  '这儿填写 发件箱 QQ号码
dd = "*********"  '这儿填写 发件箱 QQ密码
' 写这个 东西主要是方便 BAT 的调用
' 运行方法为 SendMail.vbs "418682275@QQ.com" "这是一封测试邮件" "C:\test.txt"
' 以上方法 会发送一份主题《这是一封测试邮件》内容为 C:\test.txt 内容的邮件 到作者 邮箱
'  如果 C:\test.txt 文件不存在   将以 "C:\test.txt" 作为内容发送
Set argv = WScript.Arguments
If argv.Count = 0 Then
  MsgBox "运行参数: 收件箱 主题 内容"+chr(13)+"例如: 418682275@QQ.com 这是一封测试邮件 这是测试邮件内容"+chr(13)+"内容可以是文本  也可以是文本文件路径(此处是绝对路径)"+chr(13)+"本代码为 QQ邮箱发送   发送失败不会提示"+chr(13)+""+chr(13)+"简爱 GouJi.org", 64+4096, "简爱 GouJi.org"
  WScript.Quit
End If
on error resume next
Set Fso = CreateObject("Scripting.FileSystemObject")
File = argv(2)
If Fso.FileExists(File) Then
  Set frn = Fso.opentextfile(File,1)
  nei = frn.readall
Else
  nei = File
End If
Set Email = CreateObject("CDO.Message")
strName = "http://schemas.microsoft.com/cdo/configuration/"
Email.From = qq&"@qq.com"
Email.To = argv(0)
Email.Subject = argv(1)
Email.Textbody = nei&vbCrLf&vbCrLf&"简爱: http://GouJi.org"
with Email.Configuration.Fields
 .Item(strName & "sendusing") = 2 
 .Item(strName & "smtpserver") = "smtp.qq.com"
 .Item(strName & "smtpserverport") = 25
 .Item(strName & "smtpauthenticate") = 1 
 .Item(strName & "sendusername") = qq
 .Item(strName & "sendpassword") = dd
 .Update
End With
Email.send

本文出自简爱博客,转载时请注明出处及相应链接。

评论

  1. 大海风2014-12-08 08:40回复

    [呲牙/]路过看看

  2. 盘玩天下2014-12-04 12:47回复

    测试下

  3. 我啊是神2014-11-16 20:06回复

    请问贵站的站点副标题怎么弄动态的,谢谢

发表评论

电子邮件地址不会被公开。必填项已用*标注