on error resume next Set Args = WScript.Arguments For I = 0 to Args.Count - 1 LogTxt = LogTxt & Args(I) Next Set Args = nothing writelog(LogTxt) public function writelog(logstr) Dim fsl,flog Set fsl=CreateObject("Scripting.FileSystemObject") if Not (fsl.FileExists("C:\Users\andrewb.SA\Documents\TEST.log"))=true Then Set flog=fsl.CreateTextFile("C:\Users\andrewb.SA\Documents\TEST.log",true) flog.WriteLine(now() & " " & logstr) flog.Close Else Dim fll Set fll=fsl.OpenTextFile("C:\Users\andrewb.SA\Documents\TEST.log",8,true) fll.WriteLine(now() & " " & logstr) fll.Close Set fll=Nothing End if Set flog=nothing Set fsl=nothing End function 'Uncomment the sub and 'end sub lines to use this in a program. 'Leaving these commented will allow you 'to run this as a standalone script 'sub SendAttach() 'Open mail, adress, attach report dim objOutlk 'Outlook dim objMail 'Email item dim strMsg const olMailItem = 0 'Create a new message set objOutlk = createobject("Outlook.Application") set objMail = objOutlk.createitem(olMailItem) objMail.To = "andrewb@sauto.co.uk" objMail.cc = "" 'Enter an address here to include a carbon copy; bcc is for blind carbon copy's 'Set up Subject Line objMail.subject = "You have a new SMS " & cstr(day(now)) & "/" & cstr(month(now)) & "/" & cstr(year(now)) 'Add the body strMsg = "Find attached SMS" & vbcrlf strMsg = strMsg & "test1" 'To add an attachment, use: objMail.attachments.add("C:\Users\andrewb.SA\Documents\test.log") objMail.body = strMsg objMail.send 'Clean up set objMail = nothing set objOutlk = nothing 'end sub