Цитата staw2ros:
И как это можно реализовать с данным скриптом? »
|
Сие может выглядеть, например, так:
Цитата Iska:
Передавайте скрипту пути к ним аргументами. »
|
читать дальше »
Код:

Option Explicit
Const cdoSendUsingPort = 2
Const cdoBasic = 1
Const strPartSchema = "http://schemas.microsoft.com/cdo/configuration/"
Dim objFSO
Dim strArg
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
If WScript.Arguments.Count <> 0 Then
With WScript.CreateObject("CDO.Message")
With .Configuration.Fields
.Item(strPartSchema & "sendusing") = cdoSendUsingPort
.Item(strPartSchema & "smtpauthenticate") = cdoBasic
.Item(strPartSchema & "smtpserver") = "smtp.mail.ru"
.Item(strPartSchema & "smtpserverport") = 25
.Item(strPartSchema & "sendusername") = "login"
.Item(strPartSchema & "sendpassword") = "password"
.Update
End With
.To = "to@mail.com"
.From = "from@mail.com"
.Subject = "Subject"
.TextBody = "TextBody"
For Each strArg In WScript.Arguments
If objFSO.FileExists(strArg) Then
.AddAttachment strArg
Else
WScript.Echo "Can't find file [" & strArg & "]"
WScript.Quit 2
End If
Next
.Send
End With
Else
WScript.Echo "Usage: " & WScript.ScriptName & " <file1> [<file2>] … [<fileN>]"
WScript.Quit 1
End If
Set objFSO = Nothing
WScript.Quit 0
Пример вызова скрипта:
Код:

script.vbs "E:\Песочница\0039\Copy-Script.ps1" "E:\Песочница\0039\file_versions.ps1" "E:\Песочница\0054\0003.cmd"
Цитата Iska:
…посредством указанного аргументом текстового файла, содержащего пути к прикрепляемым файлам. »
|
читать дальше »
Код:

Option Explicit
Const ForReading = 1
Const cdoSendUsingPort = 2
Const cdoBasic = 1
Const strPartSchema = "http://schemas.microsoft.com/cdo/configuration/"
Dim objFSO
Dim strFile4Files
Dim strFile
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
If WScript.Arguments.Count = 1 Then
strFile4Files = WScript.Arguments.Item(1)
If objFSO.FileExists(strFile4Files) Then
With WScript.CreateObject("CDO.Message")
With .Configuration.Fields
.Item(strPartSchema & "sendusing") = cdoSendUsingPort
.Item(strPartSchema & "smtpauthenticate") = cdoBasic
.Item(strPartSchema & "smtpserver") = "smtp.mail.ru"
.Item(strPartSchema & "smtpserverport") = 25
.Item(strPartSchema & "sendusername") = "login"
.Item(strPartSchema & "sendpassword") = "password"
.Update
End With
.To = "to@mail.com"
.From = "from@mail.com"
.Subject = "Subject"
.TextBody = "TextBody"
Set objTS = objFSO.OpenTextFile(strFile4Files, ForReading)
Do Until objTS.AtEndOfStream
strFile = objTS.ReadLine()
If objFSO.FileExists(strFile) Then
.AddAttachment strFile
Else
WScript.Echo "Can't find file [" & strFile & "]"
WScript.Quit 2
End If
Loop
objTS.Close
Set objTS = Nothing
.Send
End With
Else
WScript.Echo "Can't find file [" & strFile4Files & "]"
End If
Else
WScript.Echo "Usage: " & WScript.ScriptName & " <file with paths>"
WScript.Quit 1
End If
Set objFSO = Nothing
WScript.Quit 0
Пример вызова скрипта:
Код:

script.vbs "E:\Песочница\0055\FileList.txt"
Пример содержимого файла «E:\Песочница\0055\FileList.txt»:
Код:

E:\Песочница\0039\Copy-Script.ps1
E:\Песочница\0039\file_versions.ps1
E:\Песочница\0054\0003.cmd