Posted on 2011-04-25
Last Modified: 2012-05-11
I am in the process a creating a batch file that copies files between servers.

Would like to be able to send an email to the end user when the batch process is complete and successful.

Would like to include (just the names of the files)  in the email the files that were copies, the size, and date/time stamp.

I have done some pretty basic scripting things in the past but is a little different.
Question by:yostnet
    LVL 8

    Accepted Solution

    i think you can go this way..just basic script.If modificaation needed do

    @echo off
    set source=source_File_name
    set destination=Destination_Flie_name
    xcopy %source% %destination%
    cscript /nologo sendemail.vbs

    Open in new window

    you shold create a VB script with below conect in the same folder.

    'Script to send email
    'Configuration Field,Modify below..
    SMTPServer = "yoursmtpserver_IP_OR_NAME"
    Recipient = "THE_EMAIL_RECIPIENT"
    From = "THE_EMAIL_FROM_ID"
    Subject = "Test email"
    Message = "THE EMAIL SUBJECT"
    'If there is no attachment needed,Remove or comment above line.
    'To comment the line,just add " ' " before the line.
    'DO not modify anything below this line.
    GenericSendmail SMTPserver, From, Recipient, Subject, Message
    Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message)
    set msg = WScript.CreateObject("CDO.Message")
    msg.From = From
    msg.To = Recipient
    msg.Subject = Subject
    msg.TextBody = Message
    msg.Configuration.Fields ("") = SMTPServer
    msg.Configuration.Fields("") = 2
    End Sub

    Open in new window

    Make sure to modify the configuration feild of VBS according to your Email server config..
    LVL 51

    Assisted Solution

    by:Bill Prew
    Another approach for sending email right from a BAT file is to use the BLAT util (plenty of samples and articles on EE on this).

    LVL 10

    Expert Comment

    What if you write something that looks like a batch file and that would contain words/commands that represents the logic and processes of what you want to do? The objectif is not that it works, it's just so we can have a clear picture.
    LVL 8

    Expert Comment

     ^^^  +1

    Author Closing Comment

    thanks for the help

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
    TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now