Hi all,
New to VBScripting and have a question on my script. I have a CSV which has 3 columns (subject, email address, Body). I'm do a while lop to open the csv and read in the lines and while not at the end of the stream send an email. Issue is that its only sending the first email then erroring with
Any ideas?
Code is below
Dim olApp
Dim objMailItem
Dim arr,strLine
Const ForReading = 1
strInput = "C:\Scripts\mails.csv"
Set fso = CreateObject("Scripting.FileSystemObject")
Set olApp = CreateObject("Outlook.Application")
Set objMailItem = olApp.CreateItem(0)
Set inputFile = fso.OpenTextFile(strInput, ForReading)
Do While Not inputFile.AtEndOfStream
arr = Split(inputFile.ReadLine, ",")
objMailItem.Subject = arr(0)
objMailItem.To = arr(1)
objMailItem.Body = arr(2)
objMailItem.Send
Loop
Set olApp = Nothing
Set objMailItem = Nothing