1

通过 Outlook 编辑和发送邮件的 VBS 脚本

 3 years ago
source link: https://zhiqiang.org/coding/auto-send-email-with-vbs.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

通过 Outlook 编辑和发送邮件的 VBS 脚本

作者: 张志强

, 发表于 2010-12-12

, 共 952 字 , 共阅读 384 次

系列:办公自动化

查看该系列所有文章

工作中或多或少有些琐碎的事情,比如每天要发送和接受数据,很多是通过邮件的方式传递的。之前写过如何在 Outlook 里自动保存附件,这里再发一个如何更方便地发送带附件的邮件。

主要是针对下面这个需求:每天需要发送一些特定的附件给特定的人,邮件有差不多固定格式的标题和正文,所带附件文件名的格式也比较固定,比如以当天日期为文件名的文件。

下载下面的 vbs 脚本随便放到某个地方,点击运行,将自动调用 Outlook 建立一封邮件(机器里需安装 Office Outlook ),自动填入预先指定的收件人,邮件标题为 "报告 2010-12-9"(后面日期可根据当天日期自动改变),并且载入 D 盘根目录下的"report 2010-12-9.docx"和"report 2010-12-9.pdf"作为附件。

下载地址

可对其进行自定义,用写字板打开这个 vbs 文件,修改下面这段即可:

' receiptions 为收件人列表
' Subject 为邮件标题
' Body 为邮件正文
' Attachments 为附件列表,每个附件都需附带路径。
' autoSend 设置是否直接发送,设置为False时将停留在最后窗口,需手动按Outlook的发送按钮进行发送

receiptions = "[email protected]; [email protected]"
Subject = "报告 " & sdt
Body = "附件是今日报告,请查收。"
Attachments = Array("D:\report " & sdt & ".docx", "D:\report " & sdt & ".pdf")
autoSend = False

该脚本需要你使用 Outlook 作为邮件软件,上面的脚本在 Outlook 2007 下测试通过,但在别的版本下应该也能用的。对于 Outlook Express 和 Lotus 都能实现同样的东西,这里不阐述了。

Q. E. D.

avatar-0.jpg

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK