Sending email / paging in a windows batch file
Hi,
First, I would like to apologize if this is in anyway not related to Transact-SQL. And I would greatly appreciate your help for this is an urgent requirement. I just have a batch file which performs an ftp. Now, if the ftp process aborts, i would like to send out a mail and page the on-call person. I am not sure how to do this - I mean how to send email and send message through pager. My batch file is called by the Windows scheduler.
Thanks in advance.
Answers
I use vbscript to handle emails with CDOSYS.
Code SnippetSet objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Reconnet Database Activity"
objMessage.From = "fromaddress@domain.com"
objMessage.To = "toaddress@domain.com"objMessage.Bcc = ""
objMessage.TextBody = "MessageBody is here."
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.domain.com"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Just call the vbscript using cscript if it fails to send the alert out.Hi,
check out the below link
http://www.paulsadowski.com/WSH/cmdmail.htm
Please let me know if you have any questions.
Thanks -- Vj
http://dotnetvj.blogspot.com
All Replies
I use vbscript to handle emails with CDOSYS.
Code SnippetSet objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Reconnet Database Activity"
objMessage.From = "fromaddress@domain.com"
objMessage.To = "toaddress@domain.com"objMessage.Bcc = ""
objMessage.TextBody = "MessageBody is here."
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.domain.com"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Just call the vbscript using cscript if it fails to send the alert out.Hi Jonathan,
I am not familiar with vbscript. I just want to create a batch file that sends a mail. If you can, please give me an example.
Thank you..
- There is no way to do it in a batch file that I know of. There are certain limitations in what can and can not be done in batch files. This is where you have to extend outside of them into scripting with VBScript to extend the functionality.
Hi,
check out the below link
http://www.paulsadowski.com/WSH/cmdmail.htm
Please let me know if you have any questions.
Thanks -- Vj
http://dotnetvj.blogspot.com
- This worked perfectly for sending an e-mail when a service fails to restart. Thank you!


