使用批处理文件发送电子邮件 [英] Sending email using Batch file
问题描述
我已经配置了我的办公室,我的身份证和前景感到非常新的批量脚本。什么是发送通过批处理文件的电子邮件给我的同事最简单的方法(简单的code)。
I have my outlook configured with my office id and am extremely new to batch scripting. What is the simplest way (simplest code) to send an email via batch file to my colleague.
感谢
推荐答案
我可以看到三个选项供您:
I can see 3 options for you:
-
的底线是有批量没有内置的方式,但也有第三方的工具,如BLAT等,可以从一个批处理文件被调用。
The bottom line is there's no built-in way in batch, but there are third-party tools like blat etc. that can be called from a batch file.
您可以启用Windows的安装SMTP服务器。然后运行PowerShell脚本:
You can enable the installed SMTP Server of Windows. And then run a Powershell script:
$smtpServer = "system.abc.com"
$smtpFrom = "dontreply@abc.com"
$smtpTo = "something@abc.com"
$messageSubject = "Put your subject here"
$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
$message.Subject = $messageSubject
$message.IsBodyHTML = $true
$message.Body = Get-Content debug.txt
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)
您可以启用Windows的安装SMTP服务器。然后运行一个VBScript:
You can enable the installed SMTP Server of Windows. And then run a VBScript:
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const FileToBeUsed = "debug.txt"
Dim objCDO1
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(FileToBeUsed, ForReading)
Set objCDO1 = CreateObject("CDO.Message")
objCDO1.Textbody = f.ReadAll
f.Close
objCDO1.TO ="something@abc.com"
objCDO1.From = "dontreply@abc.com"
objCDO1.Subject = "Put your subject here"
objCDO1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration /sendusing") = 2
objCDO1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration /smtpserver") = "system.abc.com"
objCDO1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration /smtpserverport") = 25
objCDO1.Configuration.Fields.Update
objCDO1.Send
Set f = Nothing
Set fso = Nothing
选择是你的。
这篇关于使用批处理文件发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!