How to send multiple attachments concatenated into the same variable in vbscript

Asked

Viewed 10 times

1

'Declaring internal variables read files

Dim files

Set objFSO = Createobject("Scripting.Filesystemobject")

'Setting source folder

objStartFolder = "C: ORIGIN TEST"

Set objFolder = objFSO.Getfolder(objStartFolder)

'Setting the Destination folder

pastureDestino = "C: DESTINATION TEST"

'Listing all the files in the folder and contacting in a single name for sending by email

Set colFiles = objFolder.Files

For Each objFile in colFiles

If arquivos = "" Then

arquivos = objStartFolder & objFile.Name

Else    

arquivos = arquivos & " | " & objStartFolder & objFile.Name 

End If

arquivo = objStartFolder & objFile.Name

objFSO.CopyFile arquivo, pastaDestino

Next

'Sending by email vbScript

' Declaring the internal variables of sending by email vbScript

Set emailObj = Createobject("CDO.Message")

emailObj.From = "[email protected]"

emailObj.To = "[email protected]"

emailObj.Subject = "Testing"

emailObj.Textbody = "Test "&Date()&" "&Time()

emailObj.Addattachment files

Set emailConfig = emailObj.Configuration

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

emailConfig.Fields.Update

emailObj.Send

If err.number = 0 then Msgbox "Done"

'Performing file history and deleting from current folder.

Const Deletereadonly = TRUE

For Each objFile in colFiles

file = objStartFolder & objFile.Name

objFSO.Deletefile(file), Deletereadonly

Next

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.