我想要一个批处理文件程序来获得电子邮件。
例如,我有一个文本文件main.txt,其中包含一些数据
我想把这个记到我的邮箱id上。你能在这个编程中帮我吗?
提前谢谢。
发布于 2012-09-18 01:03:31
如果你有一个可以发送邮件的电子邮件服务器,我建议你首先推荐Blat,正如PA的评论所提到的那样。
如果你运行的是Microsoft Outlook电子邮件客户端,你可以用一个VBScript脚本来驱动它--严格来说不是一个批处理文件,但VBScript通常是Windows的一部分。当然,您可以使用批处理文件来调用带有正确参数的vbscript文件。
(我曾使用此技术在Outlook中安排事情-安排在特定时间发送具有特定主题的电子邮件。)
'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
使用下面这样的命令调用它
sendmail.vbs My_Subject_Line contents_file.txt
https://stackoverflow.com/questions/12257316
复制相似问题