NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
set Email = CreateObject("CDO.Message")
Email.From = "zmaxxxxxxx@126.com" '发信人地址
Email.To = "4965655555548@qq.com" '收信人地址(qq也可)
Email.Subject = "花三千" '邮件主题
x="E:\基础知识\一键收发邮件.txt" '发信内容写在e:\111.txt中
y="E:\小试牛刀\bat2.txt" '这是需发送的附件
Set fso=CreateObject("Scripting.FileSystemObject")
Set myfile=fso.OpenTextFile(x,1,Ture)
c=myfile.readall
myfile.Close
Email.Textbody = c
Email.AddAttachment y
with Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = "smtp.126.com" '这是126邮箱的服务器地址
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = "zmaxxxxxxx" '发信人用户名
.Item(NameSpace&"sendpassword") = "mmaxxxxxxx" '发信人密码
.Update
end with
Email.Send
Set Email=Nothing
出处:http://oraclequ.blog.163.com/blog/static/1901071022008726360560/
========================================================

原来的代码是这样的:
'By Jerry Ye
On Error Resume Next
f=InputBox("From Email:","msg","username@163.com")
smtp=InputBox("SMTP:","msg","smtp.163.com")
u=InputBox("User:","msg","username")
p=InputBox("Pass:","msg","password")
t=InputBox("To Email:","msg","username@126.com")
m=InputBox("邮件主题:","msg","Test send mail")
msg=InputBox("邮件内容:","msg","Send success")
j=InputBox("附件路径:","msg","C:\test.rar")
NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = createObject("CDO.Message")
Email.From = f
Email.To = t
Email.Subject = m
Email.Textbody = msg
Email.AddAttachment j
With Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = smtp
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = u
.Item(NameSpace&"sendpassword") = p
.update
End With
Email.Send
出处:http://zhidao.baidu.com/link?url=cw_E07n8VhyxUqA2jWdLbnr1GbT4StICLYgH_GsZGZOmPv4m4NBAiI7kv789qFr1MclePeAiwLgP__LBpsHd_K
========================================================

'用VBS写个脚本,然后用WINDOWS平台下的计划任务来调用,每天定时群发邮件.

'代码如下:  下载地址 http://www.51tiao.com/info.vbs

Dim connstr,conn
Dim sql,rs,msg

Sub OpenDB()
    ConnStr = "DSN=51tiao.Com;UID=sa;PWD=;"
    If Not IsObject(Conn) Then
        Set conn = CreateObject("Adodb.Connection")
        Conn.Open ConnStr
    End If
End Sub

OpenDB()
Send()
CloseDB()

Sub Send()
    On Error Resume Next '有错继续执行
    '邮件内容
    msg = "<html><head><title>上海跳蚤市场今日推荐 "&Date()&"</title>"&VBCRLF _
    &"<META NAME=""Author"" CONTENT=""清风, QQ: 110125707, MSN: anwellsz@msn.com"">"&VBCRLF _
    &"<style type='text/css'>"&VBCRLF _
    &"<!--"&vbcrlf _
    &"td,form,select,input,p,table,.font {font-size: 12px;line-height: 20px}"&VBCRLF _
    &"a:link {  color: #000000;  font-size: 12px; text-decoration: none}"&VBCRLF _
    &"a:visited {  color: #000000; font-size: 12px; text-decoration: none}"&VBCRLF _
    &"a:hover {  color: #ff7f2c; font-size: 12px; text-decoration: underline}"&VBCRLF _
    &"-->"&VBCRLF _
    &"</style>"&VBCRLF _
    &"</head><body>"&VBCRLF _
    &"<table width=640>"&VBCRLF _
    &"<tr><td align=right>今日推荐信息&nbsp;&nbsp;"&Year(Date())&"年"&Month(Date())&"月"&Day(Date())&"日&nbsp; <a href=""http://www.51tiao.com"" target=""_blank""><FONT size=3><b>上海跳蚤市场</b></font></a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table></div></td></tr></table>"&VBCRLF _
    &"<table width=640>"&VBCRLF _
    &"<tr bgColor='#FF9D5C'><td height=3></td></tr><tr><td>&nbsp;</td></tr><tr>"&VBCRLF _
    &"<td>"&VBCRLF _
    &"  <ul>"&VBCRLF _
    &"    <p>"
    sql = "select distinct top 100 a.infoid,a.Strtitle from newinfoarticle a "_
    &"inner join Newinfoprop b "_
    &"on a.infoid = b.infoid and a.intgood = 1 and a.intshenhe = 1 and b.rid1 = 908 and datediff(d,createtime,getdate())=0 "_
    &"order by a.infoid desc"
    Set rs = conn.execute(sql)
    If rs.eof Then
        Wscript.Echo "没有记录!"
        rs.close : Set rs = Nothing
        Exit Sub
    End If
    Do While Not rs.eof
        msg = msg&"★ <a href=""http://www.51tiao.com/4/Show.asp?ID="&rs("infoid")&""" title = """&rs("strtitle")&""" target=""_blank"">"_
        &rs("Strtitle")&"</a><br>"&VBCRLF
    Rs.MoveNext
    Loop
    Rs.close : set Rs=Nothing
    msg = msg &  "</ul></p>"&VBCRLF _
    &"</td>"&VBCRLF _
    &"</tr><tr><td>&nbsp;</td></tr><tr bgColor='#FF9D5C'><td height=3></td></tr>"&VBCRLF _
    &"<tr align=right><td><a href=""http://www.51tiao.com"" target=""_blank""><FONT face='Arial Black' size=3>51Tiao.Com</FONT></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td></tr>"&VBCRLF _
    &"</table><p></p></body></html>"
   
    '取得邮件地址
    Dim i,total,jmail
    i = 1
    Dim BadMail '不接收的邮件列表 格式 '邮件地址','邮件地址'
    BadMail = "'123@163.com','122@126.com'"
    sql = "Select distinct b.stremail From userinfo a inner join userinfo_1 b "_
    &"on a.id = b.intuserid and b.stremail <> '' and (charindex('3',a.StruserLevel)>0 or charindex('4',a.StruserLevel)>0) "_
    &"and b.stremail not in ("&BadMail&") "_
    &"order by b.stremail"
    Set rs = CreateObject("Adodb.Recordset")
    rs.open sql,conn,1,1
    total = rs.recordcount
    If rs.eof Then
        Wscript.Echo "没有用户!"
        rs.close : Set rs = Nothing
        Exit Sub
    End If

'每二十个邮件地址发送一次
    For i = 1 To total
        If i Mod 20 = 1 Then
            Set jmail = CreateObject("JMAIL.Message")   '建立发送邮件的对象
            'jmail.silent = true    '屏蔽例外错误,返回FALSE跟TRUE两值
             jmail.Logging = True    '记录日志
            jmail.Charset = "GB2312"     '邮件的文字编码
            jmail.ContentType = "text/html"    '邮件的格式为HTML格式或纯文本
        End If
        jmail.AddRecipient rs(0)
        If i Mod 20 = 0 Or i = 665 Then
            jmail.From = "info At 51tiao"   '发件人的E-MAIL地址
            jmail.FromName = "上海跳蚤市场"   '发件人的名称
            jmail.MailServerUserName = "info"     '登录邮件服务器的用户名 (您的邮件地址)
            jmail.MailServerPassword = "123123"     '登录邮件服务器的密码 (您的邮件密码)
            jmail.Subject = "上海跳蚤市场今日推荐 "&Year(Date())&"年"&Month(Date())&"月"&Day(Date())&"日"    '邮件的标题
            jmail.Body = msg      '邮件的内容
            jmail.Priority = 3      '邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值
            jmail.Send("mail.51tiao.com")     '执行邮件发送(通过邮件服务器地址)
            jmail.Close()  
            set jmail = Nothing
        End If
    rs.movenext
    Next
    rs.close : Set rs = Nothing
   
    '记录日志在C:/jmail年月日.txt
    Const DEF_FSOString = "Scripting.FileSystemObject"
    Dim fso,txt
    Set fso = CreateObject(DEF_FSOString)
    Set txt=fso.CreateTextFile("C:/jmail"&DateValue(Date())&".txt",true)
    txt.Write "邮件发送成功,共发送了"&total&"封邮件,发送于 "&Now()&"<Br><Br>"
    txt.Write jmail.log
    Set txt = Nothing
    Set fso = Nothing
    Wscript.Echo "邮件发送成功,共发送了"&total&"封邮件,发送于 "&Now()
End Sub

Sub CloseDB()
    If IsObject(conn) Then
        Conn.close : Set Conn = Nothing
    End If
End Sub

使用VBS发邮件的更多相关文章

  1. 用VBS脚本发邮件

    需求是这样的:针对账号的管理,如果发现该账号的管理员给账号加了批注,(比如要过期,修改密码,完善资料等),就需要找到这样的账号及其管理的邮件,然后发邮件给他们的管理员同时抄送给账号以达到提醒的目的.那 ...

  2. Windows下bat脚本自动发邮件

    摘要:说明:很多木马会利用自身的程序截取系统敏感文件或信息发往指定的邮箱,而blat并不是木马,它小巧却有强大的发邮件功能,可不要用它做违法事,感觉和木马功能有一拼!下面先看个具体的实例(在blat同 ...

  3. # PHP - 使用PHPMailer发邮件

    PHPMailer支持多种邮件发送方式,使用起来非常简单 1.下载PHPMailer https://github.com/PHPMailer/PHPMailer,下载完成加压后, 把下边的两个文件复 ...

  4. Linux发邮件之mail命令

    一.mail命令 1.配置 vim /etc/mail.rc 文件尾增加以下内容 set from=1968089885@qq.com smtp="smtp.qq.com" set ...

  5. 测试MailUtils,作用是发邮件

    package cn.itcast.test; import java.io.IOException; import javax.mail.MessagingException; import jav ...

  6. SQL Server定时自动抓取耗时SQL并归档数据发邮件脚本分享

    SQL Server定时自动抓取耗时SQL并归档数据发邮件脚本分享 第一步建库和建表 USE [master] GO CREATE DATABASE [MonitorElapsedHighSQL] G ...

  7. 学习linux之用mail命令发邮件

    背景 这两天工作比较闲,网上各种冲浪(这个词暴露我的网龄了).看到一位大神的文章更闲 <>.端详一番,原来是用R语言拼接字符串后用shell命令发出去.发现shell命令既然还能直接发邮件 ...

  8. linux mail利用外部邮箱地址发邮件

    mail命令发送邮件需要sendmail或postfix服务 三种常用格式发信 mail -s "标题" xxx@xxx.xxx #第一种方法,你可以把当前shell当成编辑器来用 ...

  9. 打电话,发短信,发邮件,app跳转

    1.打电话 - (IBAction)callPhone1:(id)sender { NSURL *url = [NSURL URLWithString:@"tel://18500441739 ...

随机推荐

  1. Kilani and the Game CodeForces - 1105D (bfs)

    沙茶bfs打了2小时... queue入队量太大了, 放函数里直接T了, 改成全局46ms #include <iostream> #include <algorithm> # ...

  2. AND Graph CodeForces - 987F (状压)

    链接 大意:给定$m$个数, 若$x\&y=0$, 则在$x$与$y$之间连一条无向边. 求无向图的连通块个数 暴力连边显然超时的, 可以通过辅助结点优化连边, 复杂度$O(n2^n)$ #i ...

  3. homestead 添加新站点

    homestead 添加站点的时候遇到了坑,这里记录下来,也顺便给大家一个参考. 1. 首先修改homestead.yaml文件(虽然你有可能不知道这个文件在哪,但是我也不会帮你找的.) 2. 接着修 ...

  4. Visio 入门教程

    最近做一个新项目,目前在需求确立阶段,所以每天任务是写文档讨论再修改.由于是云端架构设计,避免不了图形图表配合文字说明,需要制作 E-R 图.网络图.时序图.UML 类图等,对比其他可视化图表工具,V ...

  5. 两个listbox 复制

    foreach (object obj in lbxInsure .Items)             {                 billInfo.lbxAppCus .Items.Add ...

  6. 清除mac出现的.DS_Store文件

    一.什么是.DS_Store文件 在 Mac OS X 系统下,大部分文件夹中都包含 .DS_Store 隐藏文件,这里保存着针对这个目录的特殊信息和设置配置,例如查看方式.图标大小以及这个目录的一些 ...

  7. Spring Boot 学习(一) 快速搭建SpringBoot 项目

    快速搭建一个 Spring Boot 项目 部分参考于<深入实践Spring Boot>.<Spring实战 第四版>与程序猿DD的有关博客. 参考(嘟嘟独立博客):http: ...

  8. win10解除密码

  9. SQL Server 调优系列基础篇 - 并行运算总结(二)

    前言 上一篇文章我们介绍了查看查询计划的并行运行方式. 本篇我们接着分析SQL Server的并行运算. 闲言少叙,直接进入本篇的正题. 技术准备 同前几篇一样,基于SQL Server2008R2版 ...

  10. DevExpress v18.1新版亮点——WPF篇(五)

    用户界面套包DevExpress v18.1日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress WPF v18.1 的新功能,快来下载试用新版本!点击下载& ...