nasedkin
22-06-2015, 13:10
Dim objTextStream, TXT
Set objTextStream = CreateObject("Scripting.FileSystemObject").GetFile("E:\REGL\SEND\telo1.txt").OpenAsTextStream(1)
TXT = objTextStream.ReadAll()
objTextStream.Close
Set objTextStream = Nothing
dim Mas()
Set objShellApp = CreateObject("Shell.Application")
FolderPath = "E:\REGL\SEND\"
Set objFolderItems = objShellApp.NameSpace(FolderPath).Items()
objFolderItems.Filter 64, "*.xls"
n = 0
For Each objFolderItem In objFolderItems
n = n +1
ReDIM Preserve Mas(n)
Mas(n)=objFolderItem.Path
Next
strDate=date
strTime=time
Dim oMyMail
Set oMyMail = CreateObject("CDO.Message")
oMyMail.To = "mail@mail.ru"
oMyMail.From = "Информация <robot@mail.ru>"
oMyMail.Subject = "Изменение цены от " & strTime & " " & strDate & "."
oMyMail.TextBody = TXT
lft=LBound(Mas)
rgt=UBound(Mas)
For i=lft To rgt
oMyMail.AddAttachment Mas(i)
next
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
omyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.ru"
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "robot@mail.ru"
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
oMyMail.Configuration.Fields.Update
oMyMail.Send
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oDelFolder
Dim oFileCollection
Dim oFile
Dim oFolderCollection
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "E:\REGL\SEND\"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFolderCollection = oFolder.SubFolders
set oFileCollection = oFolder.Files
for each oFile in oFileCollection
oFile.Delete(True)
Next
For each oDelFolder in oFolderCollection
oDelFolder.Delete(True)
Next
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing
================
Скрипт прикрепляет как вложения файлы из папки E:\REGL\SEND\, вставляет текст из файла E:\REGL\SEND\telo1.txt в тело письма, в теме письма отображается число, месяц, год, часы, минуты, секунды отправления письма. Затем из папки E:\REGL\SEND все файлы удаляются.
Set objTextStream = CreateObject("Scripting.FileSystemObject").GetFile("E:\REGL\SEND\telo1.txt").OpenAsTextStream(1)
TXT = objTextStream.ReadAll()
objTextStream.Close
Set objTextStream = Nothing
dim Mas()
Set objShellApp = CreateObject("Shell.Application")
FolderPath = "E:\REGL\SEND\"
Set objFolderItems = objShellApp.NameSpace(FolderPath).Items()
objFolderItems.Filter 64, "*.xls"
n = 0
For Each objFolderItem In objFolderItems
n = n +1
ReDIM Preserve Mas(n)
Mas(n)=objFolderItem.Path
Next
strDate=date
strTime=time
Dim oMyMail
Set oMyMail = CreateObject("CDO.Message")
oMyMail.To = "mail@mail.ru"
oMyMail.From = "Информация <robot@mail.ru>"
oMyMail.Subject = "Изменение цены от " & strTime & " " & strDate & "."
oMyMail.TextBody = TXT
lft=LBound(Mas)
rgt=UBound(Mas)
For i=lft To rgt
oMyMail.AddAttachment Mas(i)
next
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
omyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.ru"
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "robot@mail.ru"
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
oMyMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
oMyMail.Configuration.Fields.Update
oMyMail.Send
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oDelFolder
Dim oFileCollection
Dim oFile
Dim oFolderCollection
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "E:\REGL\SEND\"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFolderCollection = oFolder.SubFolders
set oFileCollection = oFolder.Files
for each oFile in oFileCollection
oFile.Delete(True)
Next
For each oDelFolder in oFolderCollection
oDelFolder.Delete(True)
Next
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing
================
Скрипт прикрепляет как вложения файлы из папки E:\REGL\SEND\, вставляет текст из файла E:\REGL\SEND\telo1.txt в тело письма, в теме письма отображается число, месяц, год, часы, минуты, секунды отправления письма. Затем из папки E:\REGL\SEND все файлы удаляются.