Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 使用批处理文件发送电子邮件_Batch File - Fatal编程技术网

Batch file 使用批处理文件发送电子邮件

Batch file 使用批处理文件发送电子邮件,batch-file,Batch File,我用我的office id配置了outlook,而且我对批处理脚本非常陌生。通过批处理文件向同事发送电子邮件的最简单方式(最简单的代码)是什么 谢谢我可以为您提供3个选项: 底线是批处理中没有内置的方式,但是有第三方工具,如blat等,可以从批处理文件中调用 您可以启用Windows的已安装SMTP服务器。然后运行Powershell脚本: $smtpServer = "system.abc.com" $smtpFrom = "dontreply@abc.com" $smtpTo = "some

我用我的office id配置了outlook,而且我对批处理脚本非常陌生。通过批处理文件向同事发送电子邮件的最简单方式(最简单的代码)是什么


谢谢

我可以为您提供3个选项:

  • 底线是批处理中没有内置的方式,但是有第三方工具,如blat等,可以从批处理文件中调用

  • 您可以启用Windows的已安装SMTP服务器。然后运行Powershell脚本:

    $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:

    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
    

  • 您可以选择。

    如果您可以使用外部工具,请检查blat->