Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8131523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:07:00+00:00 2026-06-06T09:07:00+00:00

I wrote a .vbs script that emails the admin with the current log file

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:07:02+00:00Added an answer on June 6, 2026 at 9:07 am

    You can;

    dim thisMonth: thisMonth = cstr(month(date))
    if (len(thisMonth) = 1) then thisMonth = "0" & thisMonth
    

    Making

    "C:\M\XYZ\2012" & thisMonth & "\" & fileName & "_DEV_Log.txt"
    

    Equal

    "C:\M\XYZ\201206\XXX_DEV_Log.txt"
    

    (year(date) for this year)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script saved in test.vbs: Set FSO = CreateObject(Scripting.FileSystemObject) Set File =
i have vbs file with a few command line utilities that need to be
I'm trying to write a VBScript (.vbs) script that uses the WScript.Shell Run() method,
I m in a very weird situation. I created a vbs script that would
i have to write a script that converts a string from a MSSQL Server
I have a binary string that I need to write to a file. I
I have to write something in vbscript that need to use a unique set.
I am trying to write a simple VBS script that will create folders on
I have a VBScript I wrote that needs to be executed from an MSI
I wrote vbscript inside my html file for my site and I can't get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.