2014-01-17 78 views
2

我的Outlook配置了我的辦公室ID,對於批處理腳本來說是非常新的。什麼是最簡單的方法(最簡單的代碼)通過批處理文件發送電子郵件給我的同事。使用批處理文件發送電子郵件

感謝

+0

如果您可以使用外部工具檢查blat - > http://www.blat.net/examples/batch.html – npocmaka

回答

1

我可以看到3個選項供您:

  1. 的底線是有批量沒有內置的方式,但也有第三方的工具,如BLAT等,可以從批處理文件中調用。

  2. 您可以啓用已安裝的Windows的SMTP服務器。然後運行Powershell腳本:

    $smtpServer = "system.abc.com" 
    $smtpFrom = "[email protected]" 
    $smtpTo = "[email protected]" 
    $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) 
    
  3. 您可以啓用安裝的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 ="[email protected]" 
    objCDO1.From = "[email protected]" 
    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 
    

任君選擇。

+0

非常感謝您 –