首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >批处理文件编程,使用文本文件数据作为电子邮件正文来获取电子邮件通知

批处理文件编程,使用文本文件数据作为电子邮件正文来获取电子邮件通知
EN

Stack Overflow用户
提问于 2012-09-04 13:31:11
回答 1查看 1.6K关注 0票数 0

我想要一个批处理文件程序来获得电子邮件。

例如,我有一个文本文件main.txt,其中包含一些数据

我想把这个记到我的邮箱id上。你能在这个编程中帮我吗?

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2012-09-18 01:03:31

如果你有一个可以发送邮件的电子邮件服务器,我建议你首先推荐Blat,正如PA的评论所提到的那样。

如果你运行的是Microsoft Outlook电子邮件客户端,你可以用一个VBScript脚本来驱动它--严格来说不是一个批处理文件,但VBScript通常是Windows的一部分。当然,您可以使用批处理文件来调用带有正确参数的vbscript文件。

(我曾使用此技术在Outlook中安排事情-安排在特定时间发送具有特定主题的电子邮件。)

代码语言:javascript
运行
复制
'SendMail.vbs

option explicit

' Script for sending mails to myself, with given subject and optionally file contents for body

' Note this only works with particular Schedule service settings, i.e.,
' it has to log on as me and have access to the Desktop

dim fso, f, oMailItem, oOlApp

' Create the mail
Set oOlApp = CreateObject("Outlook.Application")
Set oMailItem = oOlApp.CreateItem(0) '0 = olMailItem
oMailItem.Subject = WScript.Arguments(0)
oMailItem.Recipients.Add ("receiver.name@somemailserver.com")
if WScript.Arguments.Count > 1 then
    Set fso = CreateObject("Scripting.FileSystemObject")
    set f = fso.OpenTextFile(WScript.Arguments(1), 1 )
    oMailItem.Body = f.ReadAll
    f.Close
end if   
oMailItem.Send

set f = nothing
set oMailItem = nothing
set oOlApp = nothing

使用下面这样的命令调用它

代码语言:javascript
运行
复制
sendmail.vbs My_Subject_Line contents_file.txt
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12257316

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档