Quantcast
Channel: Ru.Board
Viewing all articles
Browse latest Browse all 1003977

Удаление непарных файлов с увеличением номера и отправка (24) / Удаление непарных файлов

$
0
0
Alex_Piggy:
Добрый вечер, AlexSUNder
Я, наверное, плохо объяснил. Это два РАЗНЫХ варианта. Совершенно. Поэтому строки по смыслу и дублируются ;-)
И батнику для работы нужен sed и blat, а VBS скрипту - ничего.

Цитата:
Тогда лучше из maillist.txt забирать так:   10 email10_4_qwerty@mail.com

Хорошо. Тогда вместо
('findstr "ast_totk%%j_" "%MailList%" ')
('findstr /b /c:"%%j " "%MailList%" ')

VBS с чтением из файла списка почты [more]
Код:

Public const cFolderOut="D:\Test\A\Output"
Public const cFolderIn="D:\Test\A\Input"
Public const cEmailFrom="SENDER_EMAIL"
Public const cEmailName="SENDER_LOGIN"
Public const cEmailPass="SENDER_PASS"
Public const cEmailSMTP="SENDER_SMTP"

Public const cEmailSubj="test"
Public const cEmailText="test"
Public const cEmailEncod="windows-1251"
Public const cEmailPort="25"
Public const cEmailFirstPart="email"
Public const cEmailSecondPart="_2(3...9)_qwerty@mail.com"

Public FSO,objEmail,objTextStream
Dim objRegExp,objFolderOut,Dict, MailBase

Set FSO = CreateObject("Scripting.FileSystemObject")
Set Dict = CreateObject("Scripting.Dictionary")
Set MailBase = CreateObject("Scripting.Dictionary")
Set objEmail = CreateObject("CDO.Message")
Set objRegExp = CreateObject("VBScript.RegExp")
Set objFolderIn = FSO.GetFolder(cFolderIn)
Set objFolderOut = FSO.GetFolder(cFolderOut)

vMailBase=FSO.GetParentFolderName(WScript.ScriptFullName) & "\maillist.txt"
if FSO.FileExists(vMailBase) then
Set objTextStream = FSO.OpenTextFile(vMailBase,1,False,0)
do while not objTextStream.AtEndOfStream
vstring = objTextStream.ReadLine
stringarr=split(vstring)
If not MailBase.Exists(stringarr(0)) Then MailBase.Add stringarr(0),stringarr(1) end if
loop
objTextStream.Close
Else
Msgbox "Cannot find " & vMailBase
Wscript.Quit(1)
End If

objEmail.From = cEmailFrom
objEmail.Subject = cEmailSubj
objEmail.Textbody = cEmailText
objEmail.BodyPart.Charset = cEmailEncod
objEmail.TextBodyPart.Charset= cEmailEncod
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = cEmailSMTP
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = cEmailPort
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = cEmailName
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = cEmailPass
objEmail.Configuration.Fields.Update



objRegExp.Pattern = "^ast_totk([0-9]+).*"
For each objFile in objFolderOut.Files
template = objRegExp.Replace(objFile.name, "$1")
Dict.Add template,objFile.Name
next

objRegExp.Pattern = "^otk([0-9]+).*"
For each objFile in objFolderIn.Files
template = objRegExp.Replace(objFile.name, "$1")
If Dict.Exists (template) then
objEmail.Attachments.DeleteAll
objEmail.AddAttachment FSO.BuildPath (objFolderIn.Path,objFile.Name)
objEmail.AddAttachment FSO.BuildPath (objFolderOut.Path,Dict.Item(template))
If MailBase.Exists(template) then
objEmail.To = MailBase.Item(template)
' objEmail.Send
MsgBox "SEND " & Dict.Item(template) & " + " & objFile.Name & " TO " & objEmail.To

else
MsgBox "Cannot find email for " & template
end if
Dict.Remove template
End If
next

for each FileName in Dict.Items
' FSO.DeleteFile FSO.BuildPath (objFolderOut.Path,Dict.Item(template)),1
MsgBox "DELETE " & FileName
next
[/more]

Viewing all articles
Browse latest Browse all 1003977

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>