I am writing a batch script (.bat program) to automate some tasks. And when that certain task is complete, I would like it to send an email to the admin saying if the task was completed successfully or it failed. It will figure out if the task was completed successfully or it failed by checking the log file.
Anyways, so, at the very end, I want it to send out an email. I am also trying to attach the log file, OR make make my batch script go through the log file FIND those errors and put them in a new .txt log file and THEN attach that new log file and send it to the admin.
I was trying to write the code for mail sending directly into the batch, and it kinda looked pretty messy. So, I wrote it in VBS (.vbs). I was testing it
and I keep getting the error that says that it could not connect to the server.
Here is what my .vbs script looks like:
Dim objEmail Dim mail Set objEmail = CreateObject("CDO.Message") objEmail.Subject = "DDL Deployment Success Test" objEmail.From = "email@example.com" objEmail.To = "firstname.lastname@example.org" objEmail.TextBody = "SUCCESS." objEmail.AddAttachment "c:\example.txt" objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mail.SMTPserver.com" objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objEmail.Configuration.Fields.Update objEmail.Send
Btw, I am also, not sure how to figure out my SMTP server name and all that.
Any help??? It does not have to be strictly .vbs or .bat