将单个电子邮件发送给预定义的一组人员,其中包含文件夹中的所有文件
我有一堆在文件夹“C:\Email”中更新的文件。这些是每周创建的 PDF 文件。文件数量可能在 50 到 500 之间,甚至更多。文件名是随机的。
我需要将这些文件分别发送到三个地址,例如 [email protected] ,[电子邮件受保护] 和 [电子邮件]受保护]。我无法一次性发送所有文件,它们需要单独发送。主题将是文件的名称,正文将保持不变 - “请查找附件。谢谢并致以问候,ABC”。
我一直在使用几个 Excel 工作表的组合,其中我使用命令行语法(即“C:\Program Files\Microsoft Office\Office12\Outlook.txt”)连接所有必需的参数,以得出批处理文件的文件名。 exe /c ipm.note /m "[电子邮件受保护],[电子邮件]受保护],[电子邮件受保护]&subject=<>&body=请查找附件。谢谢和问候,ABC”
这是我今天想到的最简单的事情,但它很麻烦,因为它会打开与文件一样多的 Outlook 新消息窗口,这可能会让人厌烦。其次,这不允许我发送消息 。
希望有人能够提出一个 VBS / Windows 脚本 / VBA 代码来自动化执行相同的操作
I have a bunch of files that get updated in the folder "C:\Email". These are PDF files that are created on a weekly basis. This could number from anywhere between 50 to 500 or more files. The file names are random.
I need to send out these files individually to three addresses say [email protected],[email protected] and [email protected]. I cannot send all the files in one go, they need to go individually. The subject will be the name of the file and the body will remain the same - "Please find attached file. Thanks and Regards, ABC".
I have been using a combination of a few excel sheets where i concatanate all the required parameters to to come up with the file names for a batch file using the command line syntax i.e. "C:\Program Files\Microsoft Office\Office12\Outlook.exe /c ipm.note /m "[email protected],[email protected],[email protected]&subject=<>&body=Please find attached file. Thanks and Regards, ABC"
this is the simplest thing I have come up with today but it is cumbersome as it opens up as many outlook new message windows as there are files, which can get tiresome. Secondly this does not let me send the message automatically.
Hope some one can come up with a VBS / Windows script / VBA code to automate the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试使用 CDO.Message 对象从 VBScript 发送电子邮件。以下是取自 http://www.paulsadowski.com/wsh/cdo.htm
您可以将其放入循环结构中以发送文件夹中的每个文件
You can try sending email from VBScript using a CDO.Message object. Here is an example taken from http://www.paulsadowski.com/wsh/cdo.htm
You would place this into a loop structure to send each file in the folder
将代码替换
为
Replace the code
with
使用 Dir Loop 抓取每个 PDF 文件并创建新电子邮件。像这样:
这会将电子邮件文件夹中的每个文件发送给每个收件人,但不会为每个 PDF 发送三封单独的电子邮件。如果您特别需要,可以更改代码。
Use a Dir Loop to grab each PDF file and create a new email. Something like this:
This will send each file in the Email folder to each recipient, but it doesn't send three separate emails for each PDF. If you need that specifically, the code can be changed.