内容主题windows下简单的vbscript自动发送邮件带附件

工作之余抽点时间出来写写博文,希望对新接触的朋友有帮助。今天在这里和大家一起学习一下内容主题

    1.设置cscript为指定编译器:

    在dos中执行: cscript //h:cscript //s

     

    2. 在记事本中编写vbs脚本,另存为 sendmail.vbs, 内容如下:

    Set objEmail = CreateObject("CDO.Message")

    Call SendMail()

    每日一道理
盈盈月光,我掬一杯最清的;落落余辉,我拥一缕最暖的;灼灼红叶,我拾一片最热的;萋萋芳草,我摘一束最灿的;漫漫人生,我要采撷世间最重的———毅力。

    Sub SendMail
        objEmail.From = "xxx@163.com" '发件人
        objEmail.To = "yyy@163.com" '收件人
        objEmail.Subject = "邮件主题" '电子邮件主题主题
        objEmail.Textbody = "电子邮件内容" '电子邮件内容
        objEmail.AddAttachment "c:\附件.txt" 
        objEmail.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        objEmail.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.163.com" 'SMTP服务器地址
        objEmail.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxx" '用户名
        objEmail.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxx" '密码
        objEmail.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 '明文验证
        objEmail.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'SMTP端口号
        objEmail.Configuration.Fields.Update
        objEmail.Send
End Sub

    3. 在记事本中编写bat脚本,另存为 sendmail.bat, 内容如下:

     call automail.vbs

    4. 可用windows定时任务来调用sendmail.bat.

文章结束给大家分享下程序员的一些笑话语录: 手机终究会变成PC,所以ip会比wm更加畅销,但是有一天手机强大到一定程度了就会发现只有wm的支持才能完美享受。就好比树和草,草长得再高也是草,时间到了条件成熟了树就会窜天高了。www.ishuo.cn

原文地址:https://www.cnblogs.com/xinyuyuanm/p/3093380.html