I wrote a .vbs script that emails the admin with the current log file
Here is what I have so far:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\automatic_deployment\filename.txt", ForReading)
fileName = objTextFile.ReadLine
Wscript.Echo fileName
Dim ToAddress
Dim FromAddress
Dim MessageSubject
Dim MyTime
Dim MessageBody
Dim MessageAttachment
Dim ol, ns, newMail
Dim month
ToAddress = "myaddress@myemail.com"
MessageSubject = "Deployment was successful"
MyTime = Now
MessageBody = "Successful deployment. Log file is attached."
MessageAttachment = "C:\M\XYZ\201206\"&fileName&"_DEV_Log.txt"
Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf & MyTime
newMail.RecipIents.Add(ToAddress)
newMail.Attachments.Add(MessageAttachment)
newMail.Send
objTextFile.Close
If you see, there is a variable that is called “MessageAttachment”, where the log file is being attached at. In the destination part of the log file, there is 201206, which stands for the year and month. That folder holds the logs for 2012, June. That month increments every month. As you can see, it is hardcoded.
It works fine so far. But, I would like to take it another step further, by making it a little bit more dynamic.
I want to create a variable and get the current value of the current month, and put it in that part of the source destination, like this:
month = aqDateTime.GetMonth(Date)
MessageAttachment = "C:\M\XYZ\2012"&month&"\"&fileName&"_DEV_Log.txt"
Will this work? Any help would be appreciated.
THANKS IN ADVANCE!
You can;
Making
Equal
(
year(date)for this year)